Save uncommitted config changes
Browse files at this commit41c669cf144834e7fd528d51c52df2bde4cc2e92Parent: d06029d- chore
- save uncommitted config changes
13 changed files +389 -115
- .config/btop/btop.conf +1 -1
- .config/eww/eww.yuck +1 -1
- .config/hypr/hyprland.conf +7 -7
- .config/mimeapps.list +1 -0
- .config/niri/config.kdl +9 -9
- .config/scripts/shared/media_menu.sh +103 -0
- .config/scripts/shared/playerctl-active.sh +0 -35
- .config/scripts/shared/playerctl_active.sh +61 -0
- .config/scripts/shared/show_cover.sh +1 -1
- .config/scripts/shared/song_detail_writer.sh +193 -58
- .config/scripts/shared/webapp.sh +8 -1
- .config/waybar/config-hyprland +2 -1
- .config/waybar/config-niri +2 -1
.config/btop/btop.confmodified+1 -1
| @@ -192,7 +192,7 @@ show_swap = true | |||
| 192 | swap_disk = true | 192 | swap_disk = true |
| 193 | 193 | ||
| 194 | #* If mem box should be split to also show disks info. | 194 | #* If mem box should be split to also show disks info. |
| 195 | -show_disks = true | 195 | +show_disks = false |
| 196 | 196 | ||
| 197 | #* Filter out non physical disks. Set this to False to include network disks, RAM disks and similar. | 197 | #* Filter out non physical disks. Set this to False to include network disks, RAM disks and similar. |
| 198 | only_physical = true | 198 | only_physical = true |
.config/eww/eww.yuckmodified+1 -1
| @@ -96,7 +96,7 @@ | |||
| 96 | 96 | ||
| 97 | ;; Music widget - click to play/pause, right-click to show cover | 97 | ;; Music widget - click to play/pause, right-click to show cover |
| 98 | (defwidget music-widget [] | 98 | (defwidget music-widget [] |
| 99 | - (eventbox :onclick "bash ~/.config/scripts/shared/playerctl-active.sh play-pause" | 99 | + (eventbox :onclick "bash ~/.config/scripts/shared/playerctl_active.sh play-pause" |
| 100 | :onrightclick "bash ~/.config/scripts/shared/show_cover.sh" | 100 | :onrightclick "bash ~/.config/scripts/shared/show_cover.sh" |
| 101 | :class "music-box" | 101 | :class "music-box" |
| 102 | (label :text music))) | 102 | (label :text music))) |
.config/hypr/hyprland.confmodified+7 -7
| @@ -32,8 +32,8 @@ $clipboard = cliphist list | rofi -dmenu -show-icons -i | cliphist decode | wl- | |||
| 32 | $screenshot = grim -t png - | tee "$HOME/Pictures/Screenshots/$(date '+%y%m%d_%H-%M-%S').png" | wl-copy -t image/png | 32 | $screenshot = grim -t png - | tee "$HOME/Pictures/Screenshots/$(date '+%y%m%d_%H-%M-%S').png" | wl-copy -t image/png |
| 33 | $screenshot_with_area_selector = grim -t png -g "$(slurp)" - | wl-copy -t image/png | 33 | $screenshot_with_area_selector = grim -t png -g "$(slurp)" - | wl-copy -t image/png |
| 34 | $power_menu = bash ~/.config/scripts/system/power_menu.sh | 34 | $power_menu = bash ~/.config/scripts/system/power_menu.sh |
| 35 | -$browser = flatpak run io.github.ungoogled_software.ungoogled_chromium --enable-features=MiddleClickAutoscroll | 35 | +$browser = flatpak run io.github.ungoogled_software.ungoogled_chromium --enable-features=MiddleClickAutoscroll,HardwareMediaKeyHandling |
| 36 | -$browser_unsafe = mullvad-exclude flatpak run org.chromium.Chromium --incognito --enable-features=MiddleClickAutoscroll,AllowLegacyMV2Extensions --disable-features=ExtensionManifestV2Unsupported,ExtensionManifestV2Disabled,ExtensionsManifestV3Only | 36 | +$browser_unsafe = mullvad-exclude flatpak run org.chromium.Chromium --incognito --enable-features=MiddleClickAutoscroll,HardwareMediaKeyHandling,AllowLegacyMV2Extensions --disable-features=ExtensionManifestV2Unsupported,ExtensionManifestV2Disabled,ExtensionsManifestV3Only |
| 37 | $signal = flatpak run org.signal.Signal | 37 | $signal = flatpak run org.signal.Signal |
| 38 | $deezer = mullvad-exclude flatpak run io.github.ungoogled_software.ungoogled_chromium --no-first-run --app="https://deezer.com/" --class=chrome-deezer.com__-Default --name=chrome-deezer.com__-Default --user-data-dir=/home/tahinli/.var/app/io.github.ungoogled_software.ungoogled_chromium/data/web-app-hub/profiles/VjW8vTQ3 | 38 | $deezer = mullvad-exclude flatpak run io.github.ungoogled_software.ungoogled_chromium --no-first-run --app="https://deezer.com/" --class=chrome-deezer.com__-Default --name=chrome-deezer.com__-Default --user-data-dir=/home/tahinli/.var/app/io.github.ungoogled_software.ungoogled_chromium/data/web-app-hub/profiles/VjW8vTQ3 |
| 39 | $mainMod = SUPER | 39 | $mainMod = SUPER |
| @@ -63,7 +63,7 @@ bindl = $mainMod SHIFT, M, exec, ~/.config/scripts/hyprland/toggle_monitors.sh o | |||
| 63 | bind = $mainMod SHIFT, K, exec, bash ~/.config/scripts/system/usb_menu.sh | 63 | bind = $mainMod SHIFT, K, exec, bash ~/.config/scripts/system/usb_menu.sh |
| 64 | 64 | ||
| 65 | $discord = flatpak run dev.vencord.Vesktop | 65 | $discord = flatpak run dev.vencord.Vesktop |
| 66 | -$youtube = mullvad-exclude flatpak run io.freetubeapp.FreeTube | 66 | +$youtube = mullvad-exclude flatpak run --command=bash io.freetubeapp.FreeTube -c 'true & wait; run.sh; exit $?' |
| 67 | $code = zed | 67 | $code = zed |
| 68 | $mail = flatpak run io.github.ungoogled_software.ungoogled_chromium --no-first-run --app="https://mail.proton.me/" --class=chrome-mail.proton.me__-Default --name=chrome-mail.proton.me__-Default --user-data-dir=/home/tahinli/.var/app/io.github.ungoogled_software.ungoogled_chromium/data/web-app-hub/profiles/eIpzVtL8 | 68 | $mail = flatpak run io.github.ungoogled_software.ungoogled_chromium --no-first-run --app="https://mail.proton.me/" --class=chrome-mail.proton.me__-Default --name=chrome-mail.proton.me__-Default --user-data-dir=/home/tahinli/.var/app/io.github.ungoogled_software.ungoogled_chromium/data/web-app-hub/profiles/eIpzVtL8 |
| 69 | $whatsapp = mullvad-exclude flatpak run io.github.ungoogled_software.ungoogled_chromium --no-first-run --app="https://web.whatsapp.com/" --class=chrome-web.whatsapp.com__-Default --name=chrome-web.whatsapp.com__-Default --user-data-dir=/home/tahinli/.var/app/io.github.ungoogled_software.ungoogled_chromium/data/web-app-hub/profiles/aW2IMaZ8 | 69 | $whatsapp = mullvad-exclude flatpak run io.github.ungoogled_software.ungoogled_chromium --no-first-run --app="https://web.whatsapp.com/" --class=chrome-web.whatsapp.com__-Default --name=chrome-web.whatsapp.com__-Default --user-data-dir=/home/tahinli/.var/app/io.github.ungoogled_software.ungoogled_chromium/data/web-app-hub/profiles/aW2IMaZ8 |
| @@ -168,10 +168,10 @@ bindel = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle | |||
| 168 | bindel = ,XF86MonBrightnessUp, exec, brightnessctl s 10%+ | 168 | bindel = ,XF86MonBrightnessUp, exec, brightnessctl s 10%+ |
| 169 | bindel = ,XF86MonBrightnessDown, exec, brightnessctl s 10%- | 169 | bindel = ,XF86MonBrightnessDown, exec, brightnessctl s 10%- |
| 170 | 170 | ||
| 171 | -bindl = , XF86AudioNext, exec, ~/.config/scripts/shared/playerctl-active.sh next | 171 | +bindl = , XF86AudioNext, exec, ~/.config/scripts/shared/playerctl_active.sh next |
| 172 | -bindl = , XF86AudioPause, exec, ~/.config/scripts/shared/playerctl-active.sh play-pause | 172 | +bindl = , XF86AudioPause, exec, ~/.config/scripts/shared/playerctl_active.sh play-pause |
| 173 | -bindl = , XF86AudioPlay, exec, ~/.config/scripts/shared/playerctl-active.sh play-pause | 173 | +bindl = , XF86AudioPlay, exec, ~/.config/scripts/shared/playerctl_active.sh play-pause |
| 174 | -bindl = , XF86AudioPrev, exec, ~/.config/scripts/shared/playerctl-active.sh previous | 174 | +bindl = , XF86AudioPrev, exec, ~/.config/scripts/shared/playerctl_active.sh previous |
| 175 | 175 | ||
| 176 | windowrule = match:class .*, suppress_event maximize | 176 | windowrule = match:class .*, suppress_event maximize |
| 177 | windowrule = match:class ^$, match:title ^$, match:xwayland 1, match:float 1, match:fullscreen 0, match:pin 0, no_focus on | 177 | windowrule = match:class ^$, match:title ^$, match:xwayland 1, match:float 1, match:fullscreen 0, match:pin 0, no_focus on |
.config/mimeapps.listmodified+1 -0
| @@ -61,6 +61,7 @@ x-scheme-handler/surrealist=surrealist.desktop | |||
| 61 | x-scheme-handler/openhuman=OpenHuman-handler.desktop | 61 | x-scheme-handler/openhuman=OpenHuman-handler.desktop |
| 62 | x-scheme-handler/zcode=zcode.desktop | 62 | x-scheme-handler/zcode=zcode.desktop |
| 63 | x-scheme-handler/logseq=logseq.desktop | 63 | x-scheme-handler/logseq=logseq.desktop |
| 64 | +x-scheme-handler/fluxer=app.fluxer.FluxerDesktopCanary.desktop | ||
| 64 | 65 | ||
| 65 | [Added Associations] | 66 | [Added Associations] |
| 66 | video/mp4=mpv.desktop; | 67 | video/mp4=mpv.desktop; |
.config/niri/config.kdlmodified+9 -9
| @@ -78,7 +78,7 @@ layout { | |||
| 78 | width 3 | 78 | width 3 |
| 79 | 79 | ||
| 80 | // WALLUST-GRADIENT | 80 | // WALLUST-GRADIENT |
| 81 | - active-gradient from="#9B1A1A" to="#FCAE03" angle=90 in="oklch" | 81 | + active-gradient from="#5C112D" to="#CD5B74" angle=90 in="oklch" |
| 82 | 82 | ||
| 83 | inactive-color "#595959aa" | 83 | inactive-color "#595959aa" |
| 84 | urgent-color "#9b0000" | 84 | urgent-color "#9b0000" |
| @@ -160,8 +160,8 @@ binds { | |||
| 160 | Alt+F3 hotkey-overlay-title="Clipboard history" { spawn-sh "cliphist list | rofi -dmenu -show-icons -i | cliphist decode | wl-copy"; } | 160 | Alt+F3 hotkey-overlay-title="Clipboard history" { spawn-sh "cliphist list | rofi -dmenu -show-icons -i | cliphist decode | wl-copy"; } |
| 161 | Alt+3 hotkey-overlay-title="Clipboard history" { spawn-sh "cliphist list | rofi -dmenu -show-icons -i | cliphist decode | wl-copy"; } | 161 | Alt+3 hotkey-overlay-title="Clipboard history" { spawn-sh "cliphist list | rofi -dmenu -show-icons -i | cliphist decode | wl-copy"; } |
| 162 | 162 | ||
| 163 | - Alt+F hotkey-overlay-title="Browser" { spawn-sh "flatpak run io.github.ungoogled_software.ungoogled_chromium --enable-features=MiddleClickAutoscroll"; } | 163 | + Alt+F hotkey-overlay-title="Browser" { spawn-sh "flatpak run io.github.ungoogled_software.ungoogled_chromium --enable-features=MiddleClickAutoscroll,HardwareMediaKeyHandling"; } |
| 164 | - Shift+Alt+F hotkey-overlay-title="Browser (incognito, outside VPN)" { spawn-sh "mullvad-exclude flatpak run org.chromium.Chromium --incognito --enable-features=MiddleClickAutoscroll,AllowLegacyMV2Extensions --disable-features=ExtensionManifestV2Unsupported,ExtensionManifestV2Disabled,ExtensionsManifestV3Only"; } | 164 | + Shift+Alt+F hotkey-overlay-title="Browser (incognito, outside VPN)" { spawn-sh "mullvad-exclude flatpak run org.chromium.Chromium --incognito --enable-features=MiddleClickAutoscroll,HardwareMediaKeyHandling,AllowLegacyMV2Extensions --disable-features=ExtensionManifestV2Unsupported,ExtensionManifestV2Disabled,ExtensionsManifestV3Only"; } |
| 165 | 165 | ||
| 166 | Alt+C hotkey-overlay-title="Workspace: code" { focus-workspace "code"; } | 166 | Alt+C hotkey-overlay-title="Workspace: code" { focus-workspace "code"; } |
| 167 | Alt+G hotkey-overlay-title="Workspace: github" { focus-workspace "github"; } | 167 | Alt+G hotkey-overlay-title="Workspace: github" { focus-workspace "github"; } |
| @@ -175,7 +175,7 @@ binds { | |||
| 175 | Shift+Alt+W hotkey-overlay-title="Launch: whatsapp" { spawn-sh "~/.config/scripts/shared/webapp.sh --mullvad https://web.whatsapp.com/ aW2IMaZ8"; } | 175 | Shift+Alt+W hotkey-overlay-title="Launch: whatsapp" { spawn-sh "~/.config/scripts/shared/webapp.sh --mullvad https://web.whatsapp.com/ aW2IMaZ8"; } |
| 176 | Shift+Alt+D hotkey-overlay-title="Launch: discord" { spawn-sh "flatpak run org.equicord.equibop"; } | 176 | Shift+Alt+D hotkey-overlay-title="Launch: discord" { spawn-sh "flatpak run org.equicord.equibop"; } |
| 177 | Shift+Alt+S hotkey-overlay-title="Launch: deezer" { spawn-sh "~/.config/scripts/shared/webapp.sh --mullvad https://deezer.com/ VjW8vTQ3"; } | 177 | Shift+Alt+S hotkey-overlay-title="Launch: deezer" { spawn-sh "~/.config/scripts/shared/webapp.sh --mullvad https://deezer.com/ VjW8vTQ3"; } |
| 178 | - Shift+Alt+Y hotkey-overlay-title="Launch: youtube" { spawn-sh "mullvad-exclude flatpak run io.freetubeapp.FreeTube"; } | 178 | + Shift+Alt+Y hotkey-overlay-title="Launch: youtube" { spawn-sh "mullvad-exclude flatpak run --command=bash io.freetubeapp.FreeTube -c 'true & wait; run.sh; exit $?'"; } |
| 179 | Shift+Alt+P hotkey-overlay-title="Launch: mail" { spawn-sh "~/.config/scripts/shared/webapp.sh https://mail.proton.me/ eIpzVtL8"; } | 179 | Shift+Alt+P hotkey-overlay-title="Launch: mail" { spawn-sh "~/.config/scripts/shared/webapp.sh https://mail.proton.me/ eIpzVtL8"; } |
| 180 | 180 | ||
| 181 | Mod+Shift+C { move-column-to-workspace "code"; } | 181 | Mod+Shift+C { move-column-to-workspace "code"; } |
| @@ -202,16 +202,16 @@ binds { | |||
| 202 | Mod+Shift+Escape allow-inhibiting=false { toggle-keyboard-shortcuts-inhibit; } | 202 | Mod+Shift+Escape allow-inhibiting=false { toggle-keyboard-shortcuts-inhibit; } |
| 203 | Mod+Shift+Slash { show-hotkey-overlay; } | 203 | Mod+Shift+Slash { show-hotkey-overlay; } |
| 204 | Mod+O repeat=false { toggle-overview; } | 204 | Mod+O repeat=false { toggle-overview; } |
| 205 | - Super+Alt+S allow-when-locked=true hotkey-overlay-title=null { spawn-sh "pkill orca || exec orca"; } | 205 | + // Super+Alt+S allow-when-locked=true hotkey-overlay-title=null { spawn-sh "pkill orca || exec orca"; } |
| 206 | 206 | ||
| 207 | XF86AudioRaiseVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+ -l 1.0"; } | 207 | XF86AudioRaiseVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+ -l 1.0"; } |
| 208 | XF86AudioLowerVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-"; } | 208 | XF86AudioLowerVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-"; } |
| 209 | XF86AudioMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; } | 209 | XF86AudioMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; } |
| 210 | XF86AudioMicMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"; } | 210 | XF86AudioMicMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"; } |
| 211 | - XF86AudioPlay allow-when-locked=true { spawn-sh "~/.config/scripts/shared/playerctl-active.sh play-pause"; } | 211 | + XF86AudioPlay allow-when-locked=true { spawn-sh "~/.config/scripts/shared/playerctl_active.sh play-pause"; } |
| 212 | - XF86AudioStop allow-when-locked=true { spawn-sh "~/.config/scripts/shared/playerctl-active.sh pause"; } | 212 | + XF86AudioStop allow-when-locked=true { spawn-sh "~/.config/scripts/shared/playerctl_active.sh pause"; } |
| 213 | - XF86AudioPrev allow-when-locked=true { spawn-sh "~/.config/scripts/shared/playerctl-active.sh previous"; } | 213 | + XF86AudioPrev allow-when-locked=true { spawn-sh "~/.config/scripts/shared/playerctl_active.sh previous"; } |
| 214 | - XF86AudioNext allow-when-locked=true { spawn-sh "~/.config/scripts/shared/playerctl-active.sh next"; } | 214 | + XF86AudioNext allow-when-locked=true { spawn-sh "~/.config/scripts/shared/playerctl_active.sh next"; } |
| 215 | XF86MonBrightnessUp allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "+10%"; } | 215 | XF86MonBrightnessUp allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "+10%"; } |
| 216 | XF86MonBrightnessDown allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "10%-"; } | 216 | XF86MonBrightnessDown allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "10%-"; } |
| 217 | 217 | ||
.config/scripts/shared/media_menu.shadded+103 -0
| @@ -0,0 +1,103 @@ | |||
| 1 | +#!/bin/bash | ||
| 2 | +# Media picker (rofi): choose which MPRIS player the waybar music module follows. | ||
| 3 | +# Auto (no pin file) follows the latest player; picking a player writes | ||
| 4 | +# /tmp/playerctl_pin (line 1 bus name, 2 url host, 3 base name, 4 timestamp). | ||
| 5 | +# Bound to middle-click on custom/music. | ||
| 6 | + | ||
| 7 | +PIN=/tmp/playerctl_pin | ||
| 8 | + | ||
| 9 | +notify() { | ||
| 10 | + notify-send "$@" 2>/dev/null || true | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +# host of an http(s) url, empty otherwise | ||
| 14 | +host_of() { | ||
| 15 | + local url=$1 | ||
| 16 | + [[ $url =~ ^https?:// ]] || return 0 | ||
| 17 | + sed -E 's#^[a-z]+://([^/]+).*#\1#' <<<"$url" | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +# --- collect players ---------------------------------------------------------- | ||
| 21 | + | ||
| 22 | +players=() | ||
| 23 | +while IFS= read -r p; do | ||
| 24 | + [[ -n $p ]] && players+=("$p") | ||
| 25 | +done < <(playerctl -l 2>/dev/null) | ||
| 26 | + | ||
| 27 | +if (( ${#players[@]} == 0 )); then | ||
| 28 | + notify "No media players" | ||
| 29 | + exit 0 | ||
| 30 | +fi | ||
| 31 | + | ||
| 32 | +pinned="" | ||
| 33 | +if [[ -f $PIN ]]; then | ||
| 34 | + pinned=$(sed -n 1p "$PIN" 2>/dev/null) | ||
| 35 | +fi | ||
| 36 | + | ||
| 37 | +# parallel arrays, index-aligned with players[] | ||
| 38 | +titles=() | ||
| 39 | +labels=() | ||
| 40 | +places=() | ||
| 41 | +entries=() | ||
| 42 | + | ||
| 43 | +if [[ -z $pinned ]]; then | ||
| 44 | + entries+=("📌 Auto (follow latest)") | ||
| 45 | +else | ||
| 46 | + entries+=("Auto (follow latest)") | ||
| 47 | +fi | ||
| 48 | + | ||
| 49 | +for p in "${players[@]}"; do | ||
| 50 | + status=$(playerctl -p "$p" status 2>/dev/null) | ||
| 51 | + artist=$(playerctl -p "$p" metadata artist 2>/dev/null) | ||
| 52 | + title=$(playerctl -p "$p" metadata title 2>/dev/null) | ||
| 53 | + url=$(playerctl -p "$p" metadata xesam:url 2>/dev/null) | ||
| 54 | + | ||
| 55 | + case "$status" in | ||
| 56 | + Playing) icon="▶" ;; | ||
| 57 | + Paused) icon="⏸" ;; | ||
| 58 | + *) icon="⏹" ;; | ||
| 59 | + esac | ||
| 60 | + | ||
| 61 | + if [[ -n $artist && -n $title ]]; then | ||
| 62 | + label="$artist - $title" | ||
| 63 | + elif [[ -n $title ]]; then | ||
| 64 | + label=$title | ||
| 65 | + else | ||
| 66 | + label="(no title)" | ||
| 67 | + fi | ||
| 68 | + | ||
| 69 | + host=$(host_of "$url") | ||
| 70 | + base=${p%%.*} | ||
| 71 | + place=${host:-$base} | ||
| 72 | + | ||
| 73 | + titles+=("${title:-(no title)}") | ||
| 74 | + labels+=("$label") | ||
| 75 | + places+=("$place") | ||
| 76 | + | ||
| 77 | + prefix="" | ||
| 78 | + [[ $p == "$pinned" ]] && prefix="📌 " | ||
| 79 | + entries+=("${prefix}${icon} ${label} — ${place} [${p}]") | ||
| 80 | +done | ||
| 81 | + | ||
| 82 | +# --- menu ------------------------------------------------------------------- | ||
| 83 | + | ||
| 84 | +idx=$(printf '%s\n' "${entries[@]}" | rofi -dmenu -i -p "Media" -format i) | ||
| 85 | +[[ -z $idx ]] && exit 0 | ||
| 86 | +[[ $idx =~ ^[0-9]+$ ]] || exit 0 | ||
| 87 | + | ||
| 88 | +if (( idx == 0 )); then | ||
| 89 | + rm -f "$PIN" | ||
| 90 | + notify "Media: auto" | ||
| 91 | + exit 0 | ||
| 92 | +fi | ||
| 93 | + | ||
| 94 | +(( idx <= ${#players[@]} )) || exit 0 | ||
| 95 | +i=$((idx - 1)) | ||
| 96 | +player=${players[i]} | ||
| 97 | + | ||
| 98 | +tmp=$(mktemp /tmp/playerctl_pin.XXXXXX) || exit 1 | ||
| 99 | +host=$(host_of "$(playerctl -p "$player" metadata xesam:url 2>/dev/null)") | ||
| 100 | +printf '%s\n%s\n%s\n%s\n' "$player" "$host" "${player%%.*}" "$(date +%s)" > "$tmp" | ||
| 101 | +mv -f "$tmp" "$PIN" | ||
| 102 | + | ||
| 103 | +notify "Media pinned" "${titles[i]} — ${places[i]}" | ||
.config/scripts/shared/playerctl-active.shdeleted+0 -35
| @@ -1,35 +0,0 @@ | |||
| 1 | -#!/bin/bash | ||
| 2 | -# Forward playerctl commands to the ACTIVE player: the one currently Playing, | ||
| 3 | -# else the most recently Playing (now Paused) one — the same selection | ||
| 4 | -# song_detail_writer.sh makes for the waybar display, so clicks hit the | ||
| 5 | -# player the bar is showing instead of the first in `playerctl -l` order. | ||
| 6 | -# | ||
| 7 | -# Usage: playerctl-active.sh play-pause|stop|next|previous|status|metadata ... | ||
| 8 | - | ||
| 9 | -ACTIVITY_PREFIX="/tmp/playerctl_activity_" | ||
| 10 | -sanitize() { printf '%s' "$1" | tr -c 'A-Za-z0-9._-' '_'; } | ||
| 11 | - | ||
| 12 | -chosen="" | ||
| 13 | -fallback="" | ||
| 14 | -fallback_ts=0 | ||
| 15 | -while IFS= read -r player; do | ||
| 16 | - [[ -z "$player" ]] && continue | ||
| 17 | - status=$(playerctl -p "$player" status 2>/dev/null) || continue | ||
| 18 | - if [[ "$status" == "Playing" ]]; then | ||
| 19 | - chosen="$player" | ||
| 20 | - break | ||
| 21 | - elif [[ "$status" == "Paused" ]]; then | ||
| 22 | - ts=0 | ||
| 23 | - act_file="${ACTIVITY_PREFIX}$(sanitize "$player")" | ||
| 24 | - [[ -f "$act_file" ]] && ts=$(cat "$act_file" 2>/dev/null) && [[ -z "$ts" ]] && ts=0 | ||
| 25 | - if (( ts > fallback_ts )); then | ||
| 26 | - fallback_ts="$ts" | ||
| 27 | - fallback="$player" | ||
| 28 | - fi | ||
| 29 | - fi | ||
| 30 | -done < <(playerctl -l 2>/dev/null) | ||
| 31 | - | ||
| 32 | -chosen="${chosen:-$fallback}" | ||
| 33 | -[[ -z "$chosen" ]] && exit 1 | ||
| 34 | - | ||
| 35 | -exec playerctl -p "$chosen" "$@" | ||
.config/scripts/shared/playerctl_active.shadded+61 -0
| @@ -0,0 +1,61 @@ | |||
| 1 | +#!/bin/bash | ||
| 2 | +# Forward playerctl commands to the player the bar is showing, so clicks hit | ||
| 3 | +# what song_detail_writer.sh displays instead of the first in `playerctl -l`. | ||
| 4 | +# Target order: | ||
| 5 | +# 1. /tmp/song_detail_player (the writer's current player), if still listed | ||
| 6 | +# 2. pin file line 1 (/tmp/playerctl_pin), if still listed | ||
| 7 | +# 3. Playing player with the most recent start (/tmp/playerctl_started_*) | ||
| 8 | +# 4. Paused player with the latest activity (/tmp/playerctl_activity_*) | ||
| 9 | +# | ||
| 10 | +# Usage: playerctl_active.sh play-pause|stop|next|previous|status|metadata ... | ||
| 11 | + | ||
| 12 | +ACTIVITY_PREFIX="/tmp/playerctl_activity_" | ||
| 13 | +STARTED_PREFIX="/tmp/playerctl_started_" | ||
| 14 | +CHOSEN_FILE="/tmp/song_detail_player" | ||
| 15 | +PIN_FILE="/tmp/playerctl_pin" | ||
| 16 | +sanitize() { printf '%s' "$1" | tr -c 'A-Za-z0-9._-' '_'; } | ||
| 17 | + | ||
| 18 | +list=$(playerctl -l 2>/dev/null) | ||
| 19 | +in_list() { grep -qxF -- "$1" <<< "$list"; } | ||
| 20 | + | ||
| 21 | +chosen="" | ||
| 22 | +if [[ -s "$CHOSEN_FILE" ]]; then | ||
| 23 | + cand=$(head -n 1 "$CHOSEN_FILE") | ||
| 24 | + [[ -n "$cand" ]] && in_list "$cand" && chosen="$cand" | ||
| 25 | +fi | ||
| 26 | +if [[ -z "$chosen" && -f "$PIN_FILE" ]]; then | ||
| 27 | + cand=$(head -n 1 "$PIN_FILE") | ||
| 28 | + [[ -n "$cand" ]] && in_list "$cand" && chosen="$cand" | ||
| 29 | +fi | ||
| 30 | + | ||
| 31 | +if [[ -z "$chosen" ]]; then | ||
| 32 | + best_playing="" | ||
| 33 | + best_playing_ts=-1 | ||
| 34 | + fallback="" | ||
| 35 | + fallback_ts=0 | ||
| 36 | + while IFS= read -r player; do | ||
| 37 | + [[ -z "$player" ]] && continue | ||
| 38 | + status=$(playerctl -p "$player" status 2>/dev/null) || continue | ||
| 39 | + if [[ "$status" == "Playing" ]]; then | ||
| 40 | + started=$(cat "${STARTED_PREFIX}$(sanitize "$player")" 2>/dev/null) | ||
| 41 | + [[ "$started" =~ ^[0-9]+$ ]] || started=0 | ||
| 42 | + if (( started > best_playing_ts )); then | ||
| 43 | + best_playing_ts="$started" | ||
| 44 | + best_playing="$player" | ||
| 45 | + fi | ||
| 46 | + elif [[ "$status" == "Paused" ]]; then | ||
| 47 | + ts=0 | ||
| 48 | + act_file="${ACTIVITY_PREFIX}$(sanitize "$player")" | ||
| 49 | + [[ -f "$act_file" ]] && ts=$(cat "$act_file" 2>/dev/null) && [[ -z "$ts" ]] && ts=0 | ||
| 50 | + if (( ts > fallback_ts )); then | ||
| 51 | + fallback_ts="$ts" | ||
| 52 | + fallback="$player" | ||
| 53 | + fi | ||
| 54 | + fi | ||
| 55 | + done <<< "$list" | ||
| 56 | + chosen="${best_playing:-$fallback}" | ||
| 57 | +fi | ||
| 58 | + | ||
| 59 | +[[ -z "$chosen" ]] && exit 1 | ||
| 60 | + | ||
| 61 | +exec playerctl -p "$chosen" "$@" | ||
.config/scripts/shared/show_cover.shmodified+1 -1
| @@ -1,7 +1,7 @@ | |||
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | 2 | ||
| 3 | # Get cover art URL from playerctl | 3 | # Get cover art URL from playerctl |
| 4 | -cover_url=$(bash ~/.config/scripts/shared/playerctl-active.sh metadata mpris:artUrl 2>/dev/null) | 4 | +cover_url=$(bash ~/.config/scripts/shared/playerctl_active.sh metadata mpris:artUrl 2>/dev/null) |
| 5 | 5 | ||
| 6 | if [[ -z "$cover_url" ]]; then | 6 | if [[ -z "$cover_url" ]]; then |
| 7 | notify-send "No cover art available" | 7 | notify-send "No cover art available" |
.config/scripts/shared/song_detail_writer.shmodified+193 -58
| @@ -8,16 +8,25 @@ | |||
| 8 | # the file each interval always see the live line. Whatever was in the file | 8 | # the file each interval always see the live line. Whatever was in the file |
| 9 | # before — including a leftover in-place log from an older build — is dropped. | 9 | # before — including a leftover in-place log from an older build — is dropped. |
| 10 | # | 10 | # |
| 11 | +# Pin mode: /tmp/playerctl_pin (line 1 = bus name, 2 = url host, 3 = base name, | ||
| 12 | +# 4 = pinned epoch) keeps the display on one player. While pinned the line gets | ||
| 13 | +# a 📌 prefix and holds the last good line through short gaps. | ||
| 14 | +# /tmp/song_detail_player always holds the player currently shown. | ||
| 15 | +# | ||
| 11 | # niri spawn-at-startup re-runs on compositor restart and used to stack | 16 | # niri spawn-at-startup re-runs on compositor restart and used to stack |
| 12 | # copies; newest instance takes over (singleton below). | 17 | # copies; newest instance takes over (singleton below). |
| 13 | 18 | ||
| 14 | OUTPUT_FILE="/tmp/song_detail_last" | 19 | OUTPUT_FILE="/tmp/song_detail_last" |
| 20 | +CHOSEN_FILE="/tmp/song_detail_player" | ||
| 21 | +PIN_FILE="/tmp/playerctl_pin" | ||
| 15 | POSITION_CACHE_PREFIX="/tmp/playerctl_position_cache_" | 22 | POSITION_CACHE_PREFIX="/tmp/playerctl_position_cache_" |
| 16 | ACTIVITY_PREFIX="/tmp/playerctl_activity_" | 23 | ACTIVITY_PREFIX="/tmp/playerctl_activity_" |
| 24 | +STARTED_PREFIX="/tmp/playerctl_started_" | ||
| 17 | LOCK_FILE="/tmp/song_detail_writer.lock" | 25 | LOCK_FILE="/tmp/song_detail_writer.lock" |
| 18 | PID_FILE="/tmp/song_detail_writer.pid" | 26 | PID_FILE="/tmp/song_detail_writer.pid" |
| 19 | INTERVAL=1 | 27 | INTERVAL=1 |
| 20 | EMPTY_GRACE=3 | 28 | EMPTY_GRACE=3 |
| 29 | +PIN_GRACE=300 | ||
| 21 | 30 | ||
| 22 | takeover_singleton() { | 31 | takeover_singleton() { |
| 23 | local pid | 32 | local pid |
| @@ -49,6 +58,8 @@ atomic_write() { | |||
| 49 | printf '%s\n' "$content" > "$tmp" && mv -f "$tmp" "$target" | 58 | printf '%s\n' "$content" > "$tmp" && mv -f "$tmp" "$target" |
| 50 | } | 59 | } |
| 51 | 60 | ||
| 61 | +sanitize() { printf '%s' "$1" | tr -c 'A-Za-z0-9._-' '_'; } | ||
| 62 | + | ||
| 52 | # Current line only. Truncate in place (same inode, same path) so a reader | 63 | # Current line only. Truncate in place (same inode, same path) so a reader |
| 53 | # that re-reads the file every interval gets the new content and never sees | 64 | # that re-reads the file every interval gets the new content and never sees |
| 54 | # a pile of old lines. Empty state = empty file. | 65 | # a pile of old lines. Empty state = empty file. |
| @@ -60,10 +71,26 @@ write_output() { | |||
| 60 | fi | 71 | fi |
| 61 | } | 72 | } |
| 62 | 73 | ||
| 74 | +# Written only when the shown player changes. Empty file = nothing shown. | ||
| 75 | +last_chosen="__init__" | ||
| 76 | +write_chosen() { | ||
| 77 | + [[ "$1" == "$last_chosen" ]] && return | ||
| 78 | + if [[ -z "$1" ]]; then | ||
| 79 | + : > "$CHOSEN_FILE" | ||
| 80 | + else | ||
| 81 | + atomic_write "$CHOSEN_FILE" "$1" | ||
| 82 | + fi && last_chosen="$1" | ||
| 83 | +} | ||
| 84 | + | ||
| 63 | last_emit="__init__" | 85 | last_emit="__init__" |
| 64 | empty_streak=0 | 86 | empty_streak=0 |
| 65 | last_position="" | 87 | last_position="" |
| 66 | last_track="" | 88 | last_track="" |
| 89 | +declare -A prev_status=() | ||
| 90 | +pin_missing_since=0 | ||
| 91 | +pin_noinfo_since=0 | ||
| 92 | +last_good_text="" | ||
| 93 | +text_owner="" | ||
| 67 | 94 | ||
| 68 | emit() { | 95 | emit() { |
| 69 | local out="$1" | 96 | local out="$1" |
| @@ -87,6 +114,20 @@ pango_escape() { | |||
| 87 | printf '%s' "$s" | 114 | printf '%s' "$s" |
| 88 | } | 115 | } |
| 89 | 116 | ||
| 117 | +# Url host of a player's current page; empty for non-http(s) or no url. | ||
| 118 | +host_of() { | ||
| 119 | + local url | ||
| 120 | + url=$(playerctl -p "$1" metadata xesam:url 2>/dev/null) | ||
| 121 | + case "$url" in | ||
| 122 | + http://*|https://*) printf '%s' "$url" | sed -E 's#^[a-z]+://([^/]+).*#\1#' ;; | ||
| 123 | + esac | ||
| 124 | +} | ||
| 125 | + | ||
| 126 | +# Args: name host base epoch | ||
| 127 | +write_pin() { | ||
| 128 | + atomic_write "$PIN_FILE" "$(printf '%s\n%s\n%s\n%s' "$1" "$2" "$3" "$4")" | ||
| 129 | +} | ||
| 130 | + | ||
| 90 | # File must exist for readers. Carry over at most the current line — any | 131 | # File must exist for readers. Carry over at most the current line — any |
| 91 | # accumulated log from an older append-mode build is dropped here. | 132 | # accumulated log from an older append-mode build is dropped here. |
| 92 | if [[ -s "$OUTPUT_FILE" ]]; then | 133 | if [[ -s "$OUTPUT_FILE" ]]; then |
| @@ -94,71 +135,160 @@ if [[ -s "$OUTPUT_FILE" ]]; then | |||
| 94 | else | 135 | else |
| 95 | : > "$OUTPUT_FILE" | 136 | : > "$OUTPUT_FILE" |
| 96 | fi | 137 | fi |
| 138 | +[[ -f "$CHOSEN_FILE" ]] || : > "$CHOSEN_FILE" | ||
| 97 | 139 | ||
| 98 | -while true; do | 140 | +# Sets globals: out (line to show), chosen (player shown). |
| 99 | - if ! command -v playerctl &>/dev/null; then | 141 | +# Seconds -> MM:SS, or H:MM:SS once past an hour. |
| 100 | - emit "" | 142 | +fmt_time() { |
| 101 | - sleep "$INTERVAL" | 143 | + local t=$1 |
| 102 | - continue | 144 | + if (( t >= 3600 )); then |
| 145 | + printf "%d:%02d:%02d" $((t / 3600)) $((t % 3600 / 60)) $((t % 60)) | ||
| 146 | + else | ||
| 147 | + printf "%02d:%02d" $((t / 60)) $((t % 60)) | ||
| 103 | fi | 148 | fi |
| 149 | +} | ||
| 104 | 150 | ||
| 105 | - player_list=$(playerctl -l 2>/dev/null) | 151 | +tick() { |
| 106 | - if [[ -z "$player_list" ]]; then | 152 | + out="" |
| 107 | - emit "" | 153 | + chosen="" |
| 108 | - sleep "$INTERVAL" | 154 | + local now player_list player player_status started ts act_file info |
| 109 | - continue | 155 | + local status artist title duration_us position_us duration body |
| 156 | + local best_playing="" best_playing_ts=-1 best_paused="" best_paused_ts=0 | ||
| 157 | + local pin_name="" pin_host="" pin_base="" pin_time="" pin_mode=0 pin_lines=() | ||
| 158 | + local cand cur_host icon position position_sec pos_minutes pos_seconds | ||
| 159 | + local duration_sec minutes seconds track_id POSITION_CACHE | ||
| 160 | + local -A status_of=() | ||
| 161 | + | ||
| 162 | + if ! command -v playerctl &>/dev/null; then | ||
| 163 | + return | ||
| 110 | fi | 164 | fi |
| 111 | 165 | ||
| 112 | now=$(date +%s) | 166 | now=$(date +%s) |
| 113 | - sanitize() { printf '%s' "$1" | tr -c 'A-Za-z0-9._-' '_'; } | 167 | + player_list=$(playerctl -l 2>/dev/null) |
| 114 | 168 | ||
| 115 | - best_playing="" | 169 | + # Status pass: record status, mark Playing transitions, bump activity. |
| 116 | - best_playing_ts=0 | ||
| 117 | - best_paused="" | ||
| 118 | - best_paused_ts=0 | ||
| 119 | while IFS= read -r player; do | 170 | while IFS= read -r player; do |
| 120 | [[ -z "$player" ]] && continue | 171 | [[ -z "$player" ]] && continue |
| 121 | player_status=$(playerctl -p "$player" status 2>/dev/null) | 172 | player_status=$(playerctl -p "$player" status 2>/dev/null) |
| 122 | - act_file="${ACTIVITY_PREFIX}$(sanitize "$player")" | 173 | + status_of["$player"]="$player_status" |
| 123 | if [[ "$player_status" == "Playing" ]]; then | 174 | if [[ "$player_status" == "Playing" ]]; then |
| 124 | - atomic_write "$act_file" "$now" | 175 | + if [[ "${prev_status[$player]:-}" != "Playing" ]]; then |
| 125 | - ts="$now" | 176 | + atomic_write "${STARTED_PREFIX}$(sanitize "$player")" "$(date +%s%N)" |
| 126 | - if (( ts > best_playing_ts )); then | ||
| 127 | - best_playing_ts="$ts" | ||
| 128 | - best_playing="$player" | ||
| 129 | - fi | ||
| 130 | - elif [[ "$player_status" == "Paused" ]]; then | ||
| 131 | - ts=0 | ||
| 132 | - [[ -f "$act_file" ]] && ts=$(cat "$act_file" 2>/dev/null) && [[ -z "$ts" ]] && ts=0 | ||
| 133 | - if (( ts > best_paused_ts )); then | ||
| 134 | - best_paused_ts="$ts" | ||
| 135 | - best_paused="$player" | ||
| 136 | fi | 177 | fi |
| 178 | + atomic_write "${ACTIVITY_PREFIX}$(sanitize "$player")" "$now" | ||
| 137 | fi | 179 | fi |
| 180 | + prev_status["$player"]="$player_status" | ||
| 138 | done <<< "$player_list" | 181 | done <<< "$player_list" |
| 139 | 182 | ||
| 140 | - chosen="${best_playing:-$best_paused}" | 183 | + # Forget players that vanished, so a reappearing player counts as a new start. |
| 184 | + for p in "${!prev_status[@]}"; do | ||
| 185 | + [[ -n "${status_of[$p]+x}" ]] || unset "prev_status[$p]" | ||
| 186 | + done | ||
| 141 | 187 | ||
| 142 | - if [[ -z "$chosen" ]]; then | 188 | + # Pin file, if any with a non-empty line 1. |
| 143 | - emit "" | 189 | + if [[ -f "$PIN_FILE" ]]; then |
| 144 | - sleep "$INTERVAL" | 190 | + mapfile -t pin_lines < "$PIN_FILE" |
| 145 | - continue | 191 | + pin_name="${pin_lines[0]:-}" |
| 192 | + pin_host="${pin_lines[1]:-}" | ||
| 193 | + pin_base="${pin_lines[2]:-}" | ||
| 194 | + pin_time="${pin_lines[3]:-$now}" | ||
| 195 | + [[ -z "$pin_base" ]] && pin_base="${pin_name%%.*}" | ||
| 196 | + fi | ||
| 197 | + | ||
| 198 | + if [[ -n "$pin_name" ]]; then | ||
| 199 | + pin_mode=1 | ||
| 200 | + # New pin target: drop the held text of the previous one. | ||
| 201 | + if [[ "$pin_name" != "$text_owner" ]]; then | ||
| 202 | + last_good_text="" | ||
| 203 | + text_owner="$pin_name" | ||
| 204 | + fi | ||
| 205 | + | ||
| 206 | + if [[ -n "${status_of[$pin_name]+x}" ]]; then | ||
| 207 | + # Pinned player is listed: it wins over everything else. | ||
| 208 | + pin_missing_since=0 | ||
| 209 | + chosen="$pin_name" | ||
| 210 | + cur_host=$(host_of "$pin_name") | ||
| 211 | + if [[ -n "$cur_host" && "$cur_host" != "$pin_host" ]]; then | ||
| 212 | + pin_host="$cur_host" | ||
| 213 | + write_pin "$pin_name" "$pin_host" "$pin_base" "$pin_time" | ||
| 214 | + fi | ||
| 215 | + else | ||
| 216 | + # Re-attach: same base name, and same host when one is pinned. | ||
| 217 | + cand="" | ||
| 218 | + while IFS= read -r player; do | ||
| 219 | + [[ -z "$player" || "${player%%.*}" != "$pin_base" ]] && continue | ||
| 220 | + if [[ -n "$pin_host" && "$(host_of "$player")" != "$pin_host" ]]; then | ||
| 221 | + continue | ||
| 222 | + fi | ||
| 223 | + if [[ "${status_of[$player]}" == "Playing" ]]; then | ||
| 224 | + cand="$player" | ||
| 225 | + break | ||
| 226 | + fi | ||
| 227 | + [[ -z "$cand" ]] && cand="$player" | ||
| 228 | + done <<< "$player_list" | ||
| 229 | + | ||
| 230 | + if [[ -n "$cand" ]]; then | ||
| 231 | + pin_name="$cand" | ||
| 232 | + text_owner="$cand" | ||
| 233 | + pin_missing_since=0 | ||
| 234 | + write_pin "$pin_name" "$pin_host" "$pin_base" "$pin_time" | ||
| 235 | + chosen="$pin_name" | ||
| 236 | + else | ||
| 237 | + [[ $pin_missing_since -eq 0 ]] && pin_missing_since="$now" | ||
| 238 | + if (( now - pin_missing_since < PIN_GRACE )); then | ||
| 239 | + out="📌 ⏳ ${last_good_text:-Loading…}" | ||
| 240 | + return | ||
| 241 | + fi | ||
| 242 | + rm -f "$PIN_FILE" | ||
| 243 | + notify-send "Media pin released" "$pin_name disappeared" 2>/dev/null || true | ||
| 244 | + pin_mode=0 | ||
| 245 | + pin_missing_since=0 | ||
| 246 | + fi | ||
| 247 | + fi | ||
| 146 | fi | 248 | fi |
| 147 | 249 | ||
| 148 | - info=$(playerctl -p "$chosen" metadata --format '{{status}} {{artist}} {{title}} {{mpris:length}} {{position}}' 2>/dev/null) | 250 | + if (( pin_mode == 0 )); then |
| 149 | - if [[ -z "$info" ]]; then | 251 | + # Auto: most recently started Playing player, else latest Paused. |
| 150 | - emit "" | 252 | + while IFS= read -r player; do |
| 151 | - sleep "$INTERVAL" | 253 | + [[ -z "$player" ]] && continue |
| 152 | - continue | 254 | + player_status="${status_of[$player]}" |
| 255 | + if [[ "$player_status" == "Playing" ]]; then | ||
| 256 | + started=$(cat "${STARTED_PREFIX}$(sanitize "$player")" 2>/dev/null) | ||
| 257 | + [[ "$started" =~ ^[0-9]+$ ]] || started=0 | ||
| 258 | + if (( started > best_playing_ts )); then | ||
| 259 | + best_playing_ts="$started" | ||
| 260 | + best_playing="$player" | ||
| 261 | + fi | ||
| 262 | + elif [[ "$player_status" == "Paused" ]]; then | ||
| 263 | + ts=0 | ||
| 264 | + act_file="${ACTIVITY_PREFIX}$(sanitize "$player")" | ||
| 265 | + [[ -f "$act_file" ]] && ts=$(cat "$act_file" 2>/dev/null) && [[ -z "$ts" ]] && ts=0 | ||
| 266 | + if (( ts > best_paused_ts )); then | ||
| 267 | + best_paused_ts="$ts" | ||
| 268 | + best_paused="$player" | ||
| 269 | + fi | ||
| 270 | + fi | ||
| 271 | + done <<< "$player_list" | ||
| 272 | + chosen="${best_playing:-$best_paused}" | ||
| 273 | + [[ -z "$chosen" ]] && return | ||
| 153 | fi | 274 | fi |
| 154 | 275 | ||
| 155 | - IFS=$'\t' read -r status artist title duration_us position_us <<< "$info" | 276 | + # \x1f (unit separator), not tab: tab is IFS whitespace, so an empty |
| 277 | + # artist would collapse and shift every later field left. | ||
| 278 | + info=$(playerctl -p "$chosen" metadata --format $'{{status}}\x1f{{artist}}\x1f{{title}}\x1f{{mpris:length}}\x1f{{position}}' 2>/dev/null) | ||
| 279 | + IFS=$'\x1f' read -r status artist title duration_us position_us <<< "$info" | ||
| 156 | 280 | ||
| 157 | - if [[ "$status" == "Stopped" ]]; then | 281 | + if [[ -z "$info" || "$status" == "Stopped" ]]; then |
| 158 | - emit "" | 282 | + # Pinned player with no info (slow track change): hold for a while. |
| 159 | - sleep "$INTERVAL" | 283 | + if (( pin_mode )); then |
| 160 | - continue | 284 | + [[ $pin_noinfo_since -eq 0 ]] && pin_noinfo_since="$now" |
| 285 | + if (( now - pin_noinfo_since < PIN_GRACE )); then | ||
| 286 | + out="📌 ⏳ ${last_good_text:-Loading…}" | ||
| 287 | + fi | ||
| 288 | + fi | ||
| 289 | + return | ||
| 161 | fi | 290 | fi |
| 291 | + pin_noinfo_since=0 | ||
| 162 | 292 | ||
| 163 | if [[ "$status" == "Playing" ]]; then | 293 | if [[ "$status" == "Playing" ]]; then |
| 164 | icon="▶" | 294 | icon="▶" |
| @@ -168,10 +298,7 @@ while true; do | |||
| 168 | 298 | ||
| 169 | duration="" | 299 | duration="" |
| 170 | if [[ "$duration_us" =~ ^[0-9]+$ ]]; then | 300 | if [[ "$duration_us" =~ ^[0-9]+$ ]]; then |
| 171 | - duration_sec=$((duration_us / 1000000)) | 301 | + duration=$(fmt_time $((duration_us / 1000000))) |
| 172 | - minutes=$((duration_sec / 60)) | ||
| 173 | - seconds=$((duration_sec % 60)) | ||
| 174 | - duration=$(printf "%02d:%02d" $minutes $seconds) | ||
| 175 | fi | 302 | fi |
| 176 | 303 | ||
| 177 | POSITION_CACHE="${POSITION_CACHE_PREFIX}$(sanitize "$chosen")" | 304 | POSITION_CACHE="${POSITION_CACHE_PREFIX}$(sanitize "$chosen")" |
| @@ -183,10 +310,7 @@ while true; do | |||
| 183 | fi | 310 | fi |
| 184 | if [[ "$status" == "Playing" ]]; then | 311 | if [[ "$status" == "Playing" ]]; then |
| 185 | if [[ "$position_us" =~ ^[0-9]+$ ]]; then | 312 | if [[ "$position_us" =~ ^[0-9]+$ ]]; then |
| 186 | - position_sec=$((position_us / 1000000)) | 313 | + position=$(fmt_time $((position_us / 1000000))) |
| 187 | - pos_minutes=$((position_sec / 60)) | ||
| 188 | - pos_seconds=$((position_sec % 60)) | ||
| 189 | - position=$(printf "%02d:%02d" $pos_minutes $pos_seconds) | ||
| 190 | atomic_write "$POSITION_CACHE" "$position" | 314 | atomic_write "$POSITION_CACHE" "$position" |
| 191 | last_position="$position" | 315 | last_position="$position" |
| 192 | elif [[ -n "$last_position" ]]; then | 316 | elif [[ -n "$last_position" ]]; then |
| @@ -202,21 +326,32 @@ while true; do | |||
| 202 | title=$(pango_escape "$title") | 326 | title=$(pango_escape "$title") |
| 203 | 327 | ||
| 204 | if [[ -n "$artist" && -n "$title" && -n "$duration" && -n "$position" ]]; then | 328 | if [[ -n "$artist" && -n "$title" && -n "$duration" && -n "$position" ]]; then |
| 205 | - out="$icon $artist - $title ($position / $duration)" | 329 | + body="$artist - $title ($position / $duration)" |
| 206 | elif [[ -n "$artist" && -n "$title" && -n "$duration" ]]; then | 330 | elif [[ -n "$artist" && -n "$title" && -n "$duration" ]]; then |
| 207 | - out="$icon $artist - $title ($duration)" | 331 | + body="$artist - $title ($duration)" |
| 208 | elif [[ -n "$title" && -n "$duration" && -n "$position" ]]; then | 332 | elif [[ -n "$title" && -n "$duration" && -n "$position" ]]; then |
| 209 | - out="$icon $title ($position / $duration)" | 333 | + body="$title ($position / $duration)" |
| 210 | elif [[ -n "$title" && -n "$duration" ]]; then | 334 | elif [[ -n "$title" && -n "$duration" ]]; then |
| 211 | - out="$icon $title ($duration)" | 335 | + body="$title ($duration)" |
| 212 | elif [[ -n "$artist" && -n "$title" ]]; then | 336 | elif [[ -n "$artist" && -n "$title" ]]; then |
| 213 | - out="$icon $artist - $title" | 337 | + body="$artist - $title" |
| 214 | elif [[ -n "$title" ]]; then | 338 | elif [[ -n "$title" ]]; then |
| 215 | - out="$icon $title" | 339 | + body="$title" |
| 216 | else | 340 | else |
| 217 | - out="$icon Something's Playing" | 341 | + body="Something's Playing" |
| 218 | fi | 342 | fi |
| 219 | 343 | ||
| 344 | + if (( pin_mode )); then | ||
| 345 | + last_good_text="$body" | ||
| 346 | + out="📌 $icon $body" | ||
| 347 | + else | ||
| 348 | + out="$icon $body" | ||
| 349 | + fi | ||
| 350 | +} | ||
| 351 | + | ||
| 352 | +while true; do | ||
| 353 | + tick | ||
| 354 | + write_chosen "$chosen" | ||
| 220 | emit "$out" | 355 | emit "$out" |
| 221 | sleep "$INTERVAL" | 356 | sleep "$INTERVAL" |
| 222 | done | 357 | done |
.config/scripts/shared/webapp.shmodified+8 -1
| @@ -31,7 +31,14 @@ HOST="${URL#*://}" | |||
| 31 | HOST="${HOST%%/*}" | 31 | HOST="${HOST%%/*}" |
| 32 | CLASS="chrome-${HOST}__-Default" | 32 | CLASS="chrome-${HOST}__-Default" |
| 33 | 33 | ||
| 34 | -cmd=(flatpak run "$BROWSER_ID" | 34 | +# Chromium names its MPRIS player chromium.instance<pid>, and inside a flatpak |
| 35 | +# sandbox the browser is always pid 2 — so this app, the Chromium flatpak and | ||
| 36 | +# FreeTube all fight over chromium.instance2 and only one shows in playerctl. | ||
| 37 | +# Running chromium as a child of a sandbox shell moves it to pid 3, giving the | ||
| 38 | +# web apps their own player name. The trailing `exit` stops bash from exec'ing | ||
| 39 | +# a lone command (which would keep chromium at pid 2). | ||
| 40 | +cmd=(flatpak run --command=bash "$BROWSER_ID" | ||
| 41 | + -c 'chromium "$@"; exit $?' bash | ||
| 35 | --no-first-run | 42 | --no-first-run |
| 36 | --app="$URL" | 43 | --app="$URL" |
| 37 | --class="$CLASS" | 44 | --class="$CLASS" |
.config/waybar/config-hyprlandmodified+2 -1
| @@ -81,8 +81,9 @@ | |||
| 81 | "format": "{}", | 81 | "format": "{}", |
| 82 | "exec": "cat /tmp/song_detail_last 2>/dev/null", | 82 | "exec": "cat /tmp/song_detail_last 2>/dev/null", |
| 83 | "interval": 1, | 83 | "interval": 1, |
| 84 | - "on-click": "bash ~/.config/scripts/shared/playerctl-active.sh play-pause", | 84 | + "on-click": "bash ~/.config/scripts/shared/playerctl_active.sh play-pause", |
| 85 | "on-click-right": "bash ~/.config/scripts/shared/show_cover.sh", | 85 | "on-click-right": "bash ~/.config/scripts/shared/show_cover.sh", |
| 86 | + "on-click-middle": "bash ~/.config/scripts/shared/media_menu.sh", | ||
| 86 | "on-scroll-up": "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+", | 87 | "on-scroll-up": "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+", |
| 87 | "on-scroll-down": "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-" | 88 | "on-scroll-down": "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-" |
| 88 | }, | 89 | }, |
.config/waybar/config-nirimodified+2 -1
| @@ -81,8 +81,9 @@ | |||
| 81 | "format": "{}", | 81 | "format": "{}", |
| 82 | "exec": "cat /tmp/song_detail_last 2>/dev/null", | 82 | "exec": "cat /tmp/song_detail_last 2>/dev/null", |
| 83 | "interval": 1, | 83 | "interval": 1, |
| 84 | - "on-click": "bash ~/.config/scripts/shared/playerctl-active.sh play-pause", | 84 | + "on-click": "bash ~/.config/scripts/shared/playerctl_active.sh play-pause", |
| 85 | "on-click-right": "bash ~/.config/scripts/shared/show_cover.sh", | 85 | "on-click-right": "bash ~/.config/scripts/shared/show_cover.sh", |
| 86 | + "on-click-middle": "bash ~/.config/scripts/shared/media_menu.sh", | ||
| 86 | "on-scroll-up": "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+", | 87 | "on-scroll-up": "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+", |
| 87 | "on-scroll-down": "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-" | 88 | "on-scroll-down": "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-" |
| 88 | }, | 89 | }, |