mirror of
https://github.com/hydroxycarbamide/dotfiles.git
synced 2025-05-08 05:49:06 -04:00
Add nnn
This commit is contained in:
parent
0ef5de12ac
commit
c0889285ff
58 changed files with 5175 additions and 0 deletions
40
dot_config/nnn/plugins/executable_moclyrics
Normal file
40
dot_config/nnn/plugins/executable_moclyrics
Normal file
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# Description: Fetches the lyrics of the track currently playing in MOC
|
||||
#
|
||||
# Dependencies: ddgr (https://github.com/jarun/ddgr)
|
||||
#
|
||||
# Shell: POSIX compliant
|
||||
# Author: Arun Prakash Jana
|
||||
|
||||
# Check if MOC server is running
|
||||
cmd=$(pgrep -x mocp 2>/dev/null)
|
||||
ret=$cmd
|
||||
if [ -z "$ret" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Grab the output
|
||||
out="$(mocp -i)"
|
||||
|
||||
# Check if anything is playing
|
||||
state=$(echo "$out" | grep "State:" | cut -d' ' -f2)
|
||||
if ! [ "$state" = 'PLAY' ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Try by Artist and Song Title first
|
||||
ARTIST="$(echo "$out" | grep 'Artist:' | cut -d':' -f2 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')"
|
||||
TITLE="$(echo "$out" | grep 'SongTitle:' | cut -d':' -f2 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')"
|
||||
|
||||
if [ -n "$ARTIST" ] && [ -n "$TITLE" ]; then
|
||||
ddgr -w azlyrics.com --ducky "$ARTIST" "$TITLE"
|
||||
else
|
||||
# Try by file name
|
||||
FILENAME="$(basename "$(echo "$out" | grep 'File:' | cut -d':' -f2)")"
|
||||
FILENAME="$(echo "${FILENAME%%.*}" | tr -d -)"
|
||||
|
||||
if [ -n "$FILENAME" ]; then
|
||||
ddgr -w azlyrics.com --ducky "$FILENAME"
|
||||
fi
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue