waybar playerctl
This commit is contained in:
parent
cac38a1c6a
commit
a386611f22
@ -4,13 +4,21 @@
|
||||
"height": 20, // Waybar height (to be removed for auto height)
|
||||
"spacing": 4, // Gaps between modules (4px)
|
||||
// Choose the order of the modules
|
||||
"modules-left": ["custom/appmenuicon","wlr/taskbar",
|
||||
"modules-left": [
|
||||
"custom/appmenuicon",
|
||||
"wlr/taskbar",
|
||||
],
|
||||
"modules-center": [
|
||||
"hyprland/workspaces",
|
||||
],
|
||||
"modules-right": ["custom/layout","mpd","bluetooth","pulseaudio","tray","backlight","network","clock", "battery"
|
||||
|
||||
"modules-right": [
|
||||
"group/playerctl",
|
||||
"custom/layout",
|
||||
"pulseaudio",
|
||||
"tray",
|
||||
"backlight",
|
||||
"clock",
|
||||
"battery"
|
||||
],
|
||||
"include": ["~/.config/waybar/modules.json"],
|
||||
}
|
||||
|
27
.config/waybar/custom/playerctl.sh
Executable file
27
.config/waybar/custom/playerctl.sh
Executable file
@ -0,0 +1,27 @@
|
||||
title=$(playerctl metadata --format '{{markup_escape(artist)}} {{markup_escape(title)}}')
|
||||
position=$(playerctl metadata --format '{{position}}')
|
||||
length=$(playerctl metadata --format '{{mpris:length}}')
|
||||
|
||||
# Check if both position and length are not empty
|
||||
if [[ -n "$position" && -n "$length" && -n "$title" ]]; then
|
||||
# Calculate the progress as a fraction
|
||||
progress=$(echo "scale=2; $position / $length" | bc)
|
||||
|
||||
# Calculate the length of the title
|
||||
total_slots=$((${#title}/2))
|
||||
filled_slots=$(echo "$progress * $total_slots" | bc | awk '{printf("%d", $1 + 0.5)}')
|
||||
|
||||
# Construct the progress bar string
|
||||
progress_string=""
|
||||
for ((i=1; i<=total_slots; i++)); do
|
||||
if [ $i -eq $filled_slots ]; then
|
||||
progress_string+="╡"
|
||||
elif [ $i -lt $filled_slots ]; then
|
||||
progress_string+="═"
|
||||
else
|
||||
progress_string+="─"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo $(playerctl metadata --format "{\"text\": \"$title\r$progress_string\", \"alt\": \"{{status}}\", \"class\": \"{{status}}\"}}")
|
@ -8,19 +8,14 @@
|
||||
"all-outputs": true,
|
||||
"format": "{icon}",
|
||||
"format-icons": {
|
||||
"1": "",
|
||||
"2": "",
|
||||
"2": "",
|
||||
"1": "",
|
||||
"3": "",
|
||||
"4": "",
|
||||
"urgent": "",
|
||||
"focused": "",
|
||||
"default": ""
|
||||
},
|
||||
// "format": "{icon}",
|
||||
// "format-icons": {
|
||||
// "urgent": "!",
|
||||
// "active": "*",
|
||||
// "default": "0"
|
||||
//},
|
||||
"persistent-workspaces": {
|
||||
"*": 5
|
||||
}
|
||||
@ -51,6 +46,82 @@
|
||||
"tooltip-format": "MPD (connected)",
|
||||
"tooltip-format-disconnected": "MPD (disconnected)"
|
||||
},
|
||||
"custom/playerctl": {
|
||||
"interval": 1,
|
||||
"tooltip": false,
|
||||
"return-type": "json",
|
||||
"format": "",
|
||||
"format-icons": {
|
||||
"Playing": "|>",
|
||||
"Paused": "||"
|
||||
},
|
||||
"exec": "~/.config/waybar/custom/playerctl.sh",
|
||||
"on-click-right": "playerctl next",
|
||||
"on-click": "playerctl play-pause",
|
||||
"on-scroll-up": "playerctl position 1+",
|
||||
"on-scroll-down": "playerctl position 1-",
|
||||
"signal": 5
|
||||
},
|
||||
"group/playerctl": {
|
||||
"orientation": "inherit",
|
||||
"children-class": "playerctl",
|
||||
"modules": [
|
||||
"custom/playerctl-prev",
|
||||
"custom/playerctl-pause-play",
|
||||
"custom/playerctl-next",
|
||||
"custom/playerctl-title"
|
||||
]
|
||||
|
||||
},
|
||||
"custom/playerctl-artist": {
|
||||
"interval": 1,
|
||||
"format": "{}",
|
||||
"return-type": "json",
|
||||
"exec": "playerctl metadata --format '{\"text\": \"{{markup_escape(artist)}}\", \"alt\": \"{{status}}\", \"class\": \"{{status}}\"}}'",
|
||||
"on-click": "playerctl play-pause",
|
||||
},
|
||||
"custom/playerctl-title": {
|
||||
"interval": 1,
|
||||
"format": "{}",
|
||||
"return-type": "json",
|
||||
"exec": "~/.config/waybar/custom/playerctl.sh",
|
||||
"on-click": "playerctl play-pause",
|
||||
"on-scroll-up": "playerctl position 1+",
|
||||
"on-scroll-down": "playerctl position 1-",
|
||||
},
|
||||
"custom/playerctl-prev": {
|
||||
"interval": 1,
|
||||
"format": "",
|
||||
"return-type": "json",
|
||||
"exec": "playerctl metadata --format '{\"alt\": \"{{status}}\", \"class\": \"{{status}}\"}}'",
|
||||
"on-click": "playerctl previous",
|
||||
"on-scroll-up": "playerctl position 1+",
|
||||
"on-scroll-down": "playerctl position 1-",
|
||||
},
|
||||
"custom/playerctl-pause-play": {
|
||||
"interval": 1,
|
||||
"format": "{icon}",
|
||||
"format-icons": {
|
||||
"Playing": "",
|
||||
"Paused": ""
|
||||
},
|
||||
"return-type": "json",
|
||||
"exec": "playerctl metadata --format '{\"alt\": \"{{status}}\", \"class\": \"{{status}}\"}}'",
|
||||
"on-click": "playerctl play-pause",
|
||||
"on-scroll-up": "playerctl position 1+",
|
||||
"on-scroll-down": "playerctl position 1-",
|
||||
},
|
||||
"custom/playerctl-next": {
|
||||
"interval": 1,
|
||||
"format": "",
|
||||
"return-type": "json",
|
||||
"exec": "playerctl metadata --format '{\"alt\": \"{{status}}\", \"class\": \"{{status}}\"}}'",
|
||||
"on-click": "playerctl next",
|
||||
"on-scroll-up": "playerctl position 1+",
|
||||
"on-scroll-down": "playerctl position 1-",
|
||||
},
|
||||
|
||||
|
||||
|
||||
// Taskbar
|
||||
"wlr/taskbar": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user