waybar player album cover, timebar, pomodoro timer

This commit is contained in:
parent c9253f1976
commit 04607b76a6
7 changed files with 84 additions and 161 deletions

2
.config/waybar/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
custom/cover.cache
custom/cover.jpg

View File

@ -7,6 +7,7 @@
"modules-left": [ "modules-left": [
"custom/appmenuicon", "custom/appmenuicon",
"wlr/taskbar", "wlr/taskbar",
"custom/pomodoro"
], ],
"modules-center": [ "modules-center": [
"hyprland/workspaces", "hyprland/workspaces",

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@ -1,6 +1,20 @@
title=$(playerctl metadata --format '{{markup_escape(artist)}} {{markup_escape(title)}}') title=$(playerctl metadata --format '{{markup_escape(artist)}} - {{markup_escape(title)}}')
position=$(playerctl metadata --format '{{position}}') position=$(playerctl metadata --format '{{position}}')
length=$(playerctl metadata --format '{{mpris:length}}') length=$(playerctl metadata --format '{{mpris:length}}')
artUrl=$(playerctl metadata --format "{{mpris:artUrl}}")
if [[ -n "$artUrl" ]]; then
cover=$(echo "$artUrl" | sed "s/file:\/\///g")
else
cover="$HOME/.config/waybar/custom/placeholder.jpg"
fi
if [[ "$cover" != $(cat ~/.config/waybar/custom/cover.cache) ]]; then
echo "$cover" > ~/.config/waybar/custom/cover.cache
cp $cover ~/.config/waybar/custom/cover.jpg
killall waybar && waybar &
exit
fi
# Check if both position and length are not empty # Check if both position and length are not empty
if [[ -n "$position" && -n "$length" && -n "$title" ]]; then if [[ -n "$position" && -n "$length" && -n "$title" ]]; then
@ -24,4 +38,9 @@ if [[ -n "$position" && -n "$length" && -n "$title" ]]; then
done done
fi fi
echo $(playerctl metadata --format "{\"text\": \"$title\r$progress_string\", \"alt\": \"{{status}}\", \"class\": \"{{status}}\"}}") if [[ -n "$progress_string" ]]; then
title+="\r$progress_string"
fi
echo $(playerctl metadata --format "{\"text\": \"$title\", \"alt\": \"{{status}}\", \"class\": \"{{status}}\", \"tooltip\": \"$title ({{ duration(position) }}/{{ duration(mpris:length) }})\"}")

View File

@ -0,0 +1,27 @@
#!/bin/bash
# Get the output of the pomodoro command
output=$(pomodoro -g)
# Extract the timer name and remaining time
timer_name=$(echo $output | awk '{print $1}')
remaining_time=$(echo $output | awk '{print $2}')
# Convert remaining time to seconds
remaining_seconds=$(( $(echo $remaining_time | awk -F: '{print $1 * 60 + $2}') ))
# Read the configuration file and get the total time for the current timer
config_file=~/.config/pomodoro/config
total_time=$(grep "^$timer_name" $config_file | awk '{print $2}')
# Convert total time to MM:SS format
total_minutes=$(( total_time / 60 ))
total_seconds=$(( total_time % 60 ))
total_time_formatted=$(printf "%02d:%02d" $total_minutes $total_seconds)
# Calculate the progress percentage
progress=$(( (total_time - remaining_seconds) * 100 / total_time ))
# Echo the timer name and progress
echo "{\"text\": \"$timer_name\", \"tooltip\": \"$timer_name ($remaining_time/$total_time_formatted)\", \"percentage\": $progress}"

View File

@ -1,5 +1,4 @@
{ {
// Workspaces
"hyprland/workspaces": { "hyprland/workspaces": {
"on-scroll-up": "hyprctl dispatch workspace r-1", "on-scroll-up": "hyprctl dispatch workspace r-1",
"on-scroll-down": "hyprctl dispatch workspace r+1", "on-scroll-down": "hyprctl dispatch workspace r+1",
@ -11,7 +10,7 @@
"2": "", "2": "",
"1": "", "1": "",
"3": "", "3": "",
"4": "", "4": "𝄞",
"urgent": "", "urgent": "",
"focused": "", "focused": "",
"default": "" "default": ""
@ -20,47 +19,15 @@
"*": 5 "*": 5
} }
}, },
"mpd": { "custom/pomodoro": {
"format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) ⸨{songPosition}|{queueLength}⸩ {volume}% ", "format-icons": ["🕛", "🕐", "🕑", "🕒", "🕓", "🕔", "🕕", "🕖", "🕗", "🕘", "🕙", "🕚"],
"format-disconnected": "Disconnected ", "return-type": "json",
"format-stopped": "no music", "tooltip": true,
"unknown-tag": "N/A", "format": "{icon} {}",
"interval": 5, "on-click": "pomodoro",
"consume-icons": { "on-click-right": "pomodoro -k",
"on": " " "exec": "~/.config/waybar/custom/pomodoro.sh",
}, "interval": 1
"random-icons": {
"off": "<span color=\"#f53c3c\"></span> ",
"on": " "
},
"repeat-icons": {
"on": " "
},
"single-icons": {
"on": "1 "
},
"state-icons": {
"paused": "",
"playing": ""
},
"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": { "group/playerctl": {
"orientation": "inherit", "orientation": "inherit",
@ -71,36 +38,31 @@
"custom/playerctl-next", "custom/playerctl-next",
"custom/playerctl-title" "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": { "custom/playerctl-title": {
"interval": 1, "interval": 2,
"format": "{}", "format": "{}",
"hide-empty-text": true,
"return-type": "json", "return-type": "json",
"exec": "~/.config/waybar/custom/playerctl.sh", "exec": "~/.config/waybar/custom/playerctl.sh",
"on-click": "playerctl play-pause", "on-click": "playerctl play-pause",
"on-scroll-up": "playerctl position 1+", "on-scroll-up": "playerctl position 1+",
"on-scroll-down": "playerctl position 1-", "on-scroll-down": "playerctl position 1-",
}, },
"custom/playerctl-prev": { "custom/playerctl-prev": {
"interval": 1, "interval": 1,
"format": "", "format": "",
"tooltip-format": "previous track",
"return-type": "json", "return-type": "json",
"exec": "playerctl metadata --format '{\"alt\": \"{{status}}\", \"class\": \"{{status}}\"}}'", "exec": "playerctl metadata --format '{\"alt\": \"{{status}}\", \"class\": \"{{status}}\"}}'",
"on-click": "playerctl previous", "on-click": "playerctl previous",
"on-scroll-up": "playerctl position 1+", "on-scroll-up": "playerctl position 1+",
"on-scroll-down": "playerctl position 1-", "on-scroll-down": "playerctl position 1-",
}, },
"custom/playerctl-pause-play": { "custom/playerctl-pause-play": {
"interval": 1, "interval": 1,
"format": "{icon}", "format": "{icon}",
"tooltip-format": "pause/play",
"format-icons": { "format-icons": {
"Playing": "", "Playing": "",
"Paused": "" "Paused": ""
@ -108,21 +70,19 @@
"return-type": "json", "return-type": "json",
"exec": "playerctl metadata --format '{\"alt\": \"{{status}}\", \"class\": \"{{status}}\"}}'", "exec": "playerctl metadata --format '{\"alt\": \"{{status}}\", \"class\": \"{{status}}\"}}'",
"on-click": "playerctl play-pause", "on-click": "playerctl play-pause",
"on-scroll-up": "playerctl position 1+", "on-scroll-up": "playerctl position 1+",
"on-scroll-down": "playerctl position 1-", "on-scroll-down": "playerctl position 1-",
}, },
"custom/playerctl-next": { "custom/playerctl-next": {
"interval": 1, "interval": 1,
"format": "", "format": "",
"tooltip-format": "next track",
"return-type": "json", "return-type": "json",
"exec": "playerctl metadata --format '{\"alt\": \"{{status}}\", \"class\": \"{{status}}\"}}'", "exec": "playerctl metadata --format '{\"alt\": \"{{status}}\", \"class\": \"{{status}}\"}}'",
"on-click": "playerctl next", "on-click": "playerctl next",
"on-scroll-up": "playerctl position 1+", "on-scroll-up": "playerctl position 1+",
"on-scroll-down": "playerctl position 1-", "on-scroll-down": "playerctl position 1-",
}, },
// Taskbar // Taskbar
"wlr/taskbar": { "wlr/taskbar": {
"format": "{icon}", "format": "{icon}",
@ -139,7 +99,6 @@
"Foot Server": "Terminal" "Foot Server": "Terminal"
} }
}, },
// Hyprland Window // Hyprland Window
"hyprland/window": { "hyprland/window": {
"rewrite": { "rewrite": {
@ -158,29 +117,7 @@
"interval": 1 "interval": 1
}, },
// ML4W Welcome App // Wofi Application Launcher
// Empty
"custom/empty": {
"format": ""
},
// Empty
"custom/tools": {
"format": "",
"tooltip-format": "Tools"
},
// Rofi Application Launcher
"custom/appmenu": {
// START APPS LABEL
"format": "",
// END APPS LABEL
"on-click": "sleep 0.2;rofi -show drun -replace",
"on-click-right": "~/dotfiles/hypr/scripts/keybindings.sh",
"tooltip-format": "Left: Open the application launcher\nRight: Show all keybindings"
},
// Rofi Application Launcher
"custom/appmenuicon": { "custom/appmenuicon": {
"format": "", "format": "",
"on-click": "wofi --show drun", "on-click": "wofi --show drun",
@ -195,17 +132,6 @@
"tooltip-format": "Power Menu" "tooltip-format": "Power Menu"
}, },
// Keyboard State
"keyboard-state": {
"numlock": true,
"capslock": true,
"format": "{name} {icon}",
"format-icons": {
"locked": "",
"unlocked": ""
}
},
// System tray // System tray
"tray": { "tray": {
"icon-size": 21, "icon-size": 21,
@ -222,12 +148,6 @@
// END CLOCK FORMAT // END CLOCK FORMAT
}, },
// System
"custom/system": {
"format": "",
"tooltip": false
},
// CPU // CPU
"cpu": { "cpu": {
"format": "/ C {usage}% ", "format": "/ C {usage}% ",
@ -248,10 +168,6 @@
"on-click": "~/dotfiles/.settings/systeminfo.sh" "on-click": "~/dotfiles/.settings/systeminfo.sh"
}, },
"hyprland/language": {
"format": "/ K {short}"
},
// Group Hardware // Group Hardware
"group/hardware": { "group/hardware": {
"orientation": "inherit", "orientation": "inherit",
@ -279,45 +195,6 @@
] ]
}, },
// Group Links
"group/links": {
"orientation": "horizontal",
"modules": [
"custom/chatgpt",
"custom/empty"
]
},
// Group Settings
"group/settings": {
"orientation": "inherit",
"drawer": {
"transition-duration": 300,
"children-class": "not-memory",
"transition-left-to-right": true
},
"modules": [
"custom/settings",
"custom/waybarthemes",
"custom/wallpaper"
]
},
// Network
"network": {
"format": "{ifname}",
"format-wifi": " {signalStrength}%",
"format-ethernet": " {ifname}",
"format-disconnected": "Disconnected",
"tooltip-format": " {ifname} via {gwaddri}",
"tooltip-format-wifi": " {ifname} @ {essid}\nIP: {ipaddr}\nStrength: {signalStrength}%\nFreq: {frequency}MHz\nUp: {bandwidthUpBits} Down: {bandwidthDownBits}",
"tooltip-format-ethernet": " {ifname}\nIP: {ipaddr}\n up: {bandwidthUpBits} down: {bandwidthDownBits}",
"tooltip-format-disconnected": "Disconnected",
"max-length": 50,
"on-click": "alacritty --class=cursor-float -e nmtui",
"on-click-right": "~/dotfiles/.settings/networkmanager.sh"
},
// Battery // Battery
"battery": { "battery": {
"states": { "states": {
@ -364,14 +241,6 @@
"on-click": "blueman-manager", "on-click": "blueman-manager",
"format-no-controller": "" "format-no-controller": ""
}, },
// Other
"user": {
"format": "{user}",
"interval": 60,
"icon": false
},
// backlight: // backlight:
"backlight": { "backlight": {
"format": "{icon} {percent}%", "format": "{icon} {percent}%",

View File

@ -13,7 +13,7 @@
* ----------------------------------------------------- */ * ----------------------------------------------------- */
* { * {
font-family: monospace, "Fira", FontAwesome, Roboto, Helvetica, Arial, sans-serif; font-family: "Fira", FontAwesome, Roboto, Helvetica, Arial, sans-serif;
border: none; border: none;
border-radius: 0px; border-radius: 0px;
} }
@ -70,6 +70,7 @@ tooltip {
opacity: 0.8; opacity: 0.8;
padding: 20px; padding: 20px;
margin: 0px; margin: 0px;
font-family: "Fira", FontAwesome, Roboto, Helvetica, Arial, sans-serif;
} }
tooltip label { tooltip label {
@ -440,7 +441,7 @@ window#waybar.empty #window {
background-color: rgba(0, 0, 0, .2); background-color: rgba(0, 0, 0, .2);
margin-top: 2px; margin-top: 2px;
margin-right: 20px; margin-right: 20px;
padding: 4px 16px 0px; padding: 4px 16px 4px;
border: 0px; border: 0px;
font-family: monospace; font-family: monospace;
font-size: 14px; font-size: 14px;
@ -470,5 +471,9 @@ window#waybar.empty #window {
} }
#custom-playerctl-title { #custom-playerctl-title {
margin-left: 20px; margin-left: 10px;
background: url("file:///home/goodhumored/.config/waybar/custom/cover.jpg?v=1");
background-size: contain;
background-repeat: no-repeat;
padding-left: 40px;
} }