mirror of
https://github.com/jarun/nnn.git
synced 2024-12-01 02:49:44 +00:00
Add plugin to play music in MOC
This commit is contained in:
parent
9711297362
commit
edf587a48f
|
@ -9,6 +9,7 @@
|
||||||
| imgur | bash | - | Upload an image to imgur (from [imgur-screenshot](https://github.com/jomo/imgur-screenshot)) |
|
| imgur | bash | - | Upload an image to imgur (from [imgur-screenshot](https://github.com/jomo/imgur-screenshot)) |
|
||||||
| ipinfo | sh | curl, whois | Fetch external IP address and whois information |
|
| ipinfo | sh | curl, whois | Fetch external IP address and whois information |
|
||||||
| kdeconnect | sh | kdeconnect-cli | Send selected files to an Android device |
|
| kdeconnect | sh | kdeconnect-cli | Send selected files to an Android device |
|
||||||
|
| mocplay | sh | [moc](http://moc.daper.net/) | Appends (and plays, see script) selection/dir/file in moc|
|
||||||
| ndiff | bash | vimdiff | Diff for selection (limited to 2 for directories) |
|
| ndiff | bash | vimdiff | Diff for selection (limited to 2 for directories) |
|
||||||
| nmount | sh | pmount, udisks2 | Toggle mount status of a device as normal user |
|
| nmount | sh | pmount, udisks2 | Toggle mount status of a device as normal user |
|
||||||
| nwal | sh | nitrogen | Set the selected image as wallpaper using nitrogen |
|
| nwal | sh | nitrogen | Set the selected image as wallpaper using nitrogen |
|
||||||
|
|
42
plugins/mocplay
Executable file
42
plugins/mocplay
Executable file
|
@ -0,0 +1,42 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
# Description: Appends and optionally plays music in MOC
|
||||||
|
#
|
||||||
|
# Notes:
|
||||||
|
# - if selection is available, plays it, else plays the current file or directory
|
||||||
|
# - appends tracks and exits is MOC is running, else clears playlist and adds tracks
|
||||||
|
#
|
||||||
|
# Shell: POSIX compliant
|
||||||
|
# Author: Arun Prakash Jana
|
||||||
|
|
||||||
|
selection=~/.config/nnn/.selection
|
||||||
|
cmd=$(pgrep -x mocp 2>/dev/null)
|
||||||
|
ret=$cmd
|
||||||
|
|
||||||
|
if [ -s "$selection" ]; then
|
||||||
|
# try selection first
|
||||||
|
if [ -z "$ret" ]; then
|
||||||
|
# mocp not running
|
||||||
|
mocp -S
|
||||||
|
|
||||||
|
# clear selection and play
|
||||||
|
cat "$selection" | xargs -0 mocp -acp
|
||||||
|
else
|
||||||
|
# mocp running, just append
|
||||||
|
cat "$selection" | xargs -0 mocp -a
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# ensure a file/dir is passed
|
||||||
|
if ! [ -z "$1" ]; then
|
||||||
|
if [ -z "$ret" ]; then
|
||||||
|
# mocp not running
|
||||||
|
mocp -S
|
||||||
|
|
||||||
|
# clear selection and play
|
||||||
|
mocp -acp "$1"
|
||||||
|
else
|
||||||
|
# mocp running, just append
|
||||||
|
mocp -a "$1"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
Reference in a new issue