1 stable release
new 1.0.0 | Feb 17, 2025 |
---|
#338 in Command line utilities
46 downloads per month
27KB
348 lines
playit
An lightweight and simple AF media player which uses youtube for sources and plays with mpv.
The goal of this project is playing audio without worry about anything.
Also you can integrate playit
with almost everything like dmenu / rofi / tofi and their alternatives.
Installation
Note: playit requires mpv and youtube-dlp for runtime dependencies.
From Cargo
cargo install playit
From Script
curl -sSfL https://raw.githubusercontent.com/kadircy/playit/master/install.sh | sh
From repository
- Make sure you have
rust
,cargo
andgit
installed on your system.
cargo --version
rustc --version
git --version
- Clone the Git repository` The compile process takes some time because of using LTO and striping when building release binaries.
git clone https://github.com/kadircy/playit
- Compile
cargo build --release
Now you can run binary with
./target/release/playit
Usage
playit
is like other CLI programs. It accept options and print results.
When you run playit
without arguments, it will print an small help menu with flags and options.
playit --play <QUERY>
will play the given query in background and will print some information about mpv
like process id.
playit --playlist <NAME> --add <QUERY>
will add given query to the playlist with but will not play it.
playit --playlist <NAME> --play-playlist
will play the playlist.
You can see other options in details with: playit --help
Integrate
To use playit
with another programs, you can add keybindings for getting input and using this input to play media.
I prefer using launchers for getting user query or selecting playlist.
We will use Hyprland as an example WM for configurations.
dmenu
You can integrate playit in dmenu
with something like this:
# Bind a key to launch playit with dmenu input
bind = $mainMod, P, exec, playit --play "$(dmenu < /dev/null)"
Also, you can integrate playlists with something like this:
# Bind a key to select and play a playlist using dmenu
bind = $mainMod SHIFT, P, exec, QUERY=$(ls $HOME/.config/playit | sed 's/\..*$//' | dmenu) && playit --playlist "$QUERY" --play-playlist
You can add more features with similar commands. Use playit --help
for all options.
rofi
If you prefer rofi
over dmenu
, you can achieve similar functionality with this configuration:
# Bind a key to launch playit with rofi input
bind = $mainMod, P, exec, playit --play "$(rofi -dmenu < /dev/null)"
And for playlists:
# Bind a key to select and play a playlist using rofi
bind = $mainMod SHIFT, P, exec, QUERY=$(ls $HOME/.config/playit | sed 's/\..*$//' | rofi -dmenu) && playit --playlist "$QUERY" --play-playlist
tofi
For tofi, the configuration is quite similar. Here’s how you can use it to play media:
# Bind a key to launch playit with tofi input
bind = $mainMod, P, exec, playit --play "$(tofi --require-match=false < /dev/null)"
# Bind a key to select and play a playlist using tofi
bind = $mainMod, P, exec, QUERY=$(ls $HOME/.config/playit | sed 's/\..*$//' | tofi) && playit --playlist "$QUERY" --play-playlist
Contributing
Contributions are welcome! If you’d like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch
git checkout -b feature-branch
. - Make your changes and commit them
git commit -am 'Add new feature'
. - Push to your fork
git push origin feature-branch
. - Open a pull request to the main repository.
Please make sure your code follows the style and guidelines of the project. You can format codebase and lint it with this commands:
cargo fmt # format
cargo clippy # lint
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
- mpv for media playback.
- youtube-dlp for handling YouTube searchs and more.
- The developers of dmenu, rofi, and tofi for their awesome launcher programs.
Dependencies
~3–10MB
~101K SLoC