Add Playerctl Modules
This commit is contained in:
162
README.org
162
README.org
@@ -49,6 +49,7 @@
|
|||||||
- [[#dwl][dwl]]
|
- [[#dwl][dwl]]
|
||||||
- [[#disk][Disk]]
|
- [[#disk][Disk]]
|
||||||
- [[#memory][Memory]]
|
- [[#memory][Memory]]
|
||||||
|
- [[#playerctl][Playerctl]]
|
||||||
- [[#power-menu][Power Menu]]
|
- [[#power-menu][Power Menu]]
|
||||||
- [[#pulseaudio][Pulseaudio]]
|
- [[#pulseaudio][Pulseaudio]]
|
||||||
- [[#tray][Tray]]
|
- [[#tray][Tray]]
|
||||||
@@ -536,6 +537,7 @@ sleep 5
|
|||||||
"tray",
|
"tray",
|
||||||
],
|
],
|
||||||
"modules-right": [
|
"modules-right": [
|
||||||
|
"group/media-playing",
|
||||||
"pulseaudio",
|
"pulseaudio",
|
||||||
"cpu",
|
"cpu",
|
||||||
"memory",
|
"memory",
|
||||||
@@ -544,6 +546,16 @@ sleep 5
|
|||||||
"clock",
|
"clock",
|
||||||
"group/dunst",
|
"group/dunst",
|
||||||
],
|
],
|
||||||
|
"group/media-playing": {
|
||||||
|
"orientation": "horizontal",
|
||||||
|
"modules": [
|
||||||
|
"custom/media-playing-change",
|
||||||
|
"custom/media-playing-prev",
|
||||||
|
"custom/media-playing-play-pause",
|
||||||
|
"custom/media-playing-next",
|
||||||
|
],
|
||||||
|
/* "drawer": {}, */
|
||||||
|
},
|
||||||
"group/dunst": {
|
"group/dunst": {
|
||||||
"orientation": "horizontal",
|
"orientation": "horizontal",
|
||||||
"modules": [
|
"modules": [
|
||||||
@@ -629,7 +641,8 @@ window#waybar {
|
|||||||
#+BEGIN_SRC jsonc :tangle waybar/config.jsonc
|
#+BEGIN_SRC jsonc :tangle waybar/config.jsonc
|
||||||
"clock": {
|
"clock": {
|
||||||
"interval": 60,
|
"interval": 60,
|
||||||
"format": " {:%H:%M}"
|
"format": " {:%H:%M}",
|
||||||
|
"tooltip": false,
|
||||||
},
|
},
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
@@ -652,7 +665,8 @@ window#waybar {
|
|||||||
"restart-interval": 1,
|
"restart-interval": 1,
|
||||||
"on-click": "~/.scripts/dunst.sh --dnd",
|
"on-click": "~/.scripts/dunst.sh --dnd",
|
||||||
"on-click-right": "~/.scripts/dunst.sh --rofi",
|
"on-click-right": "~/.scripts/dunst.sh --rofi",
|
||||||
"tooltip": false,
|
"tooltip": true,
|
||||||
|
"tooltip-format": "Toggle Do Not Disturb",
|
||||||
},
|
},
|
||||||
"custom/dunst-clear": {
|
"custom/dunst-clear": {
|
||||||
"format": "",
|
"format": "",
|
||||||
@@ -785,6 +799,150 @@ fi
|
|||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
*** Playerctl
|
||||||
|
|
||||||
|
**** Configuration
|
||||||
|
|
||||||
|
#+BEGIN_SRC jsonc :tangle waybar/config.jsonc
|
||||||
|
"custom/media-playing-change": {
|
||||||
|
"exec": "~/.config/dwl/waybar/scripts/get-media-playing.sh",
|
||||||
|
"return-type": "json",
|
||||||
|
"restart-interval": 1,
|
||||||
|
"on-click": "~/.scripts/playerctl.sh --change",
|
||||||
|
"tooltip": true,
|
||||||
|
},
|
||||||
|
"custom/media-playing-prev": {
|
||||||
|
"format": "",
|
||||||
|
"on-click": "~/.scripts/playerctl.sh --prev",
|
||||||
|
"tooltip": false,
|
||||||
|
},
|
||||||
|
"custom/media-playing-play-pause": {
|
||||||
|
"exec": "~/.config/dwl/waybar/scripts/get-media-status-icon.sh",
|
||||||
|
"restart-interval": 1,
|
||||||
|
"on-click": "~/.scripts/playerctl.sh --play-pause",
|
||||||
|
"tooltip": false,
|
||||||
|
},
|
||||||
|
"custom/media-playing-next": {
|
||||||
|
"format": "",
|
||||||
|
"on-click": "~/.scripts/playerctl.sh --next",
|
||||||
|
"tooltip": false,
|
||||||
|
},
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
**** Styling
|
||||||
|
|
||||||
|
#+BEGIN_SRC css :tangle waybar/style.css
|
||||||
|
#custom-media-playing-change {
|
||||||
|
background: #50fa7b;
|
||||||
|
color: #282a36;
|
||||||
|
}
|
||||||
|
#custom-media-playing-prev {
|
||||||
|
background: #50fa7b;
|
||||||
|
color: #282a36;
|
||||||
|
}
|
||||||
|
#custom-media-playing-play-pause {
|
||||||
|
background: #50fa7b;
|
||||||
|
color: #282a36;
|
||||||
|
}
|
||||||
|
#custom-media-playing-next {
|
||||||
|
background: #50fa7b;
|
||||||
|
color: #282a36;
|
||||||
|
}
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
**** Script
|
||||||
|
|
||||||
|
#+BEGIN_SRC shell :shebang #!/usr/bin/env bash :tangle waybar/scripts/get-media-source-icon.sh
|
||||||
|
mediaStatus=$(playerctl --player=playerctld metadata 2>&1)
|
||||||
|
|
||||||
|
if [[ "$mediaStatus" == "No player could handle this command" ]]; then
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
trackid=$(playerctl --player=playerctld metadata --format '{{ mpris:trackid }}')
|
||||||
|
title=$(playerctl --player=playerctld metadata --format '{{ xesam:title }}')
|
||||||
|
|
||||||
|
if grep -q -i "netflix" <<< "$title"; then
|
||||||
|
echo ""
|
||||||
|
elif grep -q -i "hulu" <<< "$title"; then
|
||||||
|
echo ""
|
||||||
|
elif grep -q -i "prime video" <<< "$title"; then
|
||||||
|
echo ""
|
||||||
|
elif grep -q -i "youtube tv" <<< "$title"; then
|
||||||
|
echo ""
|
||||||
|
elif grep -q -i "chromium" <<< "$trackid"; then
|
||||||
|
echo ""
|
||||||
|
elif grep -q -i "vlc" <<< "$trackid"; then
|
||||||
|
echo ""
|
||||||
|
elif grep -q -i "spotify" <<< "$trackid"; then
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
#+BEGIN_SRC shell :shebang #!/usr/bin/env bash :tangle waybar/scripts/get-media-status-icon.sh
|
||||||
|
mediaStatus=$(`dirname $0`/get-media-status.sh)
|
||||||
|
|
||||||
|
if [[ "$mediaStatus" == "N/A" ]]; then
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
if [[ "$mediaStatus" == "Playing" ]]; then
|
||||||
|
echo ""
|
||||||
|
elif [[ "$mediaStatus" == "Paused" ]]; then
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
#+BEGIN_SRC shell :shebang #!/usr/bin/env bash :tangle waybar/scripts/get-media-status.sh
|
||||||
|
mediaStatus=$(playerctl --player=playerctld metadata 2>&1)
|
||||||
|
|
||||||
|
if [[ "$mediaStatus" == "No player could handle this command" ]]; then
|
||||||
|
echo "N/A"
|
||||||
|
else
|
||||||
|
status=$(playerctl --player=playerctld metadata --format '{{ status }}')
|
||||||
|
|
||||||
|
echo $status
|
||||||
|
fi
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
#+BEGIN_SRC shell :shebang #!/usr/bin/env bash :tangle waybar/scripts/get-media-playing.sh
|
||||||
|
mediaSourceIcon=$(`dirname $0`/get-media-source-icon.sh)
|
||||||
|
mediaStatus=$(playerctl --player=playerctld metadata 2>&1)
|
||||||
|
|
||||||
|
if [[ "$mediaStatus" == "No player could handle this command" ]]; then
|
||||||
|
artist="N/A"
|
||||||
|
title="N/A"
|
||||||
|
album="N/A"
|
||||||
|
status="N/A"
|
||||||
|
else
|
||||||
|
artist=$(playerctl --player=playerctld metadata --format '{{ xesam:artist }}')
|
||||||
|
title=$(playerctl --player=playerctld metadata --format '{{ xesam:title }}')
|
||||||
|
album=$(playerctl --player=playerctld metadata --format '{{ xesam:album }}')
|
||||||
|
status=$(playerctl --player=playerctld metadata --format '{{ status }}')
|
||||||
|
|
||||||
|
if [[ $artist == "" ]]; then
|
||||||
|
artist="N/A"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $title == "" ]]; then
|
||||||
|
title="N/A"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $album == "" ]]; then
|
||||||
|
album="N/A"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $status == "" ]]; then
|
||||||
|
status="N/A"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# echo '{"text":"'$mediaSourceIcon'","tooltip":"\t'$title'\r\t'$artist'\r\t'$album'\r\t'$status'"}' | jq --unbuffered --compact-output
|
||||||
|
echo '{"text":"'$mediaSourceIcon'","tooltip":"\t'$title'\r\t'$artist'\r\t'$album'\r\t'$status'"}'
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
*** Power Menu
|
*** Power Menu
|
||||||
|
|
||||||
**** Configuration
|
**** Configuration
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
"tray",
|
"tray",
|
||||||
],
|
],
|
||||||
"modules-right": [
|
"modules-right": [
|
||||||
|
"group/media-playing",
|
||||||
"pulseaudio",
|
"pulseaudio",
|
||||||
"cpu",
|
"cpu",
|
||||||
"memory",
|
"memory",
|
||||||
@@ -28,6 +29,16 @@
|
|||||||
"clock",
|
"clock",
|
||||||
"group/dunst",
|
"group/dunst",
|
||||||
],
|
],
|
||||||
|
"group/media-playing": {
|
||||||
|
"orientation": "horizontal",
|
||||||
|
"modules": [
|
||||||
|
"custom/media-playing-change",
|
||||||
|
"custom/media-playing-prev",
|
||||||
|
"custom/media-playing-play-pause",
|
||||||
|
"custom/media-playing-next",
|
||||||
|
],
|
||||||
|
/* "drawer": {}, */
|
||||||
|
},
|
||||||
"group/dunst": {
|
"group/dunst": {
|
||||||
"orientation": "horizontal",
|
"orientation": "horizontal",
|
||||||
"modules": [
|
"modules": [
|
||||||
@@ -59,7 +70,8 @@
|
|||||||
|
|
||||||
"clock": {
|
"clock": {
|
||||||
"interval": 60,
|
"interval": 60,
|
||||||
"format": " {:%H:%M}"
|
"format": " {:%H:%M}",
|
||||||
|
"tooltip": false,
|
||||||
},
|
},
|
||||||
|
|
||||||
"custom/dunst-status": {
|
"custom/dunst-status": {
|
||||||
@@ -67,7 +79,8 @@
|
|||||||
"restart-interval": 1,
|
"restart-interval": 1,
|
||||||
"on-click": "~/.scripts/dunst.sh --dnd",
|
"on-click": "~/.scripts/dunst.sh --dnd",
|
||||||
"on-click-right": "~/.scripts/dunst.sh --rofi",
|
"on-click-right": "~/.scripts/dunst.sh --rofi",
|
||||||
"tooltip": false,
|
"tooltip": true,
|
||||||
|
"tooltip-format": "Toggle Do Not Disturb",
|
||||||
},
|
},
|
||||||
"custom/dunst-clear": {
|
"custom/dunst-clear": {
|
||||||
"format": "",
|
"format": "",
|
||||||
@@ -108,6 +121,30 @@
|
|||||||
"tooltip-format": "RAM:\n\tUsed: {used} GiB ({percentage}%)\n\tFree: {avail} GiB\n\tTotal: {total} GiB\nSwap:\n\tUsed: {swapUsed} GiB ({swapPercentage}%)\n\tFree: {swapAvail} GiB\n\tTotal: {swapTotal} GiB",
|
"tooltip-format": "RAM:\n\tUsed: {used} GiB ({percentage}%)\n\tFree: {avail} GiB\n\tTotal: {total} GiB\nSwap:\n\tUsed: {swapUsed} GiB ({swapPercentage}%)\n\tFree: {swapAvail} GiB\n\tTotal: {swapTotal} GiB",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"custom/media-playing-change": {
|
||||||
|
"exec": "~/.config/dwl/waybar/scripts/get-media-playing.sh",
|
||||||
|
"return-type": "json",
|
||||||
|
"restart-interval": 1,
|
||||||
|
"on-click": "~/.scripts/playerctl.sh --change",
|
||||||
|
"tooltip": true,
|
||||||
|
},
|
||||||
|
"custom/media-playing-prev": {
|
||||||
|
"format": "",
|
||||||
|
"on-click": "~/.scripts/playerctl.sh --prev",
|
||||||
|
"tooltip": false,
|
||||||
|
},
|
||||||
|
"custom/media-playing-play-pause": {
|
||||||
|
"exec": "~/.config/dwl/waybar/scripts/get-media-status-icon.sh",
|
||||||
|
"restart-interval": 1,
|
||||||
|
"on-click": "~/.scripts/playerctl.sh --play-pause",
|
||||||
|
"tooltip": false,
|
||||||
|
},
|
||||||
|
"custom/media-playing-next": {
|
||||||
|
"format": "",
|
||||||
|
"on-click": "~/.scripts/playerctl.sh --next",
|
||||||
|
"tooltip": false,
|
||||||
|
},
|
||||||
|
|
||||||
"custom/power-menu": {
|
"custom/power-menu": {
|
||||||
"format": "",
|
"format": "",
|
||||||
"on-click": "rofi -show combi",
|
"on-click": "rofi -show combi",
|
||||||
|
34
waybar/scripts/get-media-playing.sh
Executable file
34
waybar/scripts/get-media-playing.sh
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
mediaSourceIcon=$(`dirname $0`/get-media-source-icon.sh)
|
||||||
|
mediaStatus=$(playerctl --player=playerctld metadata 2>&1)
|
||||||
|
|
||||||
|
if [[ "$mediaStatus" == "No player could handle this command" ]]; then
|
||||||
|
artist="N/A"
|
||||||
|
title="N/A"
|
||||||
|
album="N/A"
|
||||||
|
status="N/A"
|
||||||
|
else
|
||||||
|
artist=$(playerctl --player=playerctld metadata --format '{{ xesam:artist }}')
|
||||||
|
title=$(playerctl --player=playerctld metadata --format '{{ xesam:title }}')
|
||||||
|
album=$(playerctl --player=playerctld metadata --format '{{ xesam:album }}')
|
||||||
|
status=$(playerctl --player=playerctld metadata --format '{{ status }}')
|
||||||
|
|
||||||
|
if [[ $artist == "" ]]; then
|
||||||
|
artist="N/A"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $title == "" ]]; then
|
||||||
|
title="N/A"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $album == "" ]]; then
|
||||||
|
album="N/A"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $status == "" ]]; then
|
||||||
|
status="N/A"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# echo '{"text":"'$mediaSourceIcon'","tooltip":"\t'$title'\r\t'$artist'\r\t'$album'\r\t'$status'"}' | jq --unbuffered --compact-output
|
||||||
|
echo '{"text":"'$mediaSourceIcon'","tooltip":"\t'$title'\r\t'$artist'\r\t'$album'\r\t'$status'"}'
|
27
waybar/scripts/get-media-source-icon.sh
Executable file
27
waybar/scripts/get-media-source-icon.sh
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
mediaStatus=$(playerctl --player=playerctld metadata 2>&1)
|
||||||
|
|
||||||
|
if [[ "$mediaStatus" == "No player could handle this command" ]]; then
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
trackid=$(playerctl --player=playerctld metadata --format '{{ mpris:trackid }}')
|
||||||
|
title=$(playerctl --player=playerctld metadata --format '{{ xesam:title }}')
|
||||||
|
|
||||||
|
if grep -q -i "netflix" <<< "$title"; then
|
||||||
|
echo ""
|
||||||
|
elif grep -q -i "hulu" <<< "$title"; then
|
||||||
|
echo ""
|
||||||
|
elif grep -q -i "prime video" <<< "$title"; then
|
||||||
|
echo ""
|
||||||
|
elif grep -q -i "youtube tv" <<< "$title"; then
|
||||||
|
echo ""
|
||||||
|
elif grep -q -i "chromium" <<< "$trackid"; then
|
||||||
|
echo ""
|
||||||
|
elif grep -q -i "vlc" <<< "$trackid"; then
|
||||||
|
echo ""
|
||||||
|
elif grep -q -i "spotify" <<< "$trackid"; then
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
fi
|
12
waybar/scripts/get-media-status-icon.sh
Executable file
12
waybar/scripts/get-media-status-icon.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
mediaStatus=$(`dirname $0`/get-media-status.sh)
|
||||||
|
|
||||||
|
if [[ "$mediaStatus" == "N/A" ]]; then
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
if [[ "$mediaStatus" == "Playing" ]]; then
|
||||||
|
echo ""
|
||||||
|
elif [[ "$mediaStatus" == "Paused" ]]; then
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
fi
|
10
waybar/scripts/get-media-status.sh
Executable file
10
waybar/scripts/get-media-status.sh
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
mediaStatus=$(playerctl --player=playerctld metadata 2>&1)
|
||||||
|
|
||||||
|
if [[ "$mediaStatus" == "No player could handle this command" ]]; then
|
||||||
|
echo "N/A"
|
||||||
|
else
|
||||||
|
status=$(playerctl --player=playerctld metadata --format '{{ status }}')
|
||||||
|
|
||||||
|
echo $status
|
||||||
|
fi
|
@@ -69,6 +69,23 @@ window#waybar {
|
|||||||
color: #282a36;
|
color: #282a36;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#custom-media-playing-change {
|
||||||
|
background: #50fa7b;
|
||||||
|
color: #282a36;
|
||||||
|
}
|
||||||
|
#custom-media-playing-prev {
|
||||||
|
background: #50fa7b;
|
||||||
|
color: #282a36;
|
||||||
|
}
|
||||||
|
#custom-media-playing-play-pause {
|
||||||
|
background: #50fa7b;
|
||||||
|
color: #282a36;
|
||||||
|
}
|
||||||
|
#custom-media-playing-next {
|
||||||
|
background: #50fa7b;
|
||||||
|
color: #282a36;
|
||||||
|
}
|
||||||
|
|
||||||
#custom-power-menu {
|
#custom-power-menu {
|
||||||
background: #8be9fd;
|
background: #8be9fd;
|
||||||
color: #282a36;
|
color: #282a36;
|
||||||
|
Reference in New Issue
Block a user