Update with mpris, Macchiato catppuccin colors and awesome_switcher
This commit is contained in:
parent
64e9b9a3cb
commit
8d5ee408cf
22 changed files with 1038 additions and 79 deletions
|
@ -34,7 +34,7 @@ i3lock \
|
|||
\
|
||||
--ringver-color=${GREEN} \
|
||||
--ringwrong-color=${RED} \
|
||||
--ring-color="#fab387" \
|
||||
--ring-color="#f5e0dc" \
|
||||
\
|
||||
--line-color=${BG} \
|
||||
--separator-color=${BG} \
|
||||
|
|
99
bin/get_mpris_status.sh
Executable file
99
bin/get_mpris_status.sh
Executable file
|
@ -0,0 +1,99 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The name of polybar bar which houses the main spotify module and the control modules.
|
||||
PARENT_BAR="${1:-music}"
|
||||
PARENT_BAR_PID=$(pgrep -a "polybar" | grep "$PARENT_BAR" | cut -d" " -f1)
|
||||
|
||||
urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
|
||||
|
||||
send_hook() {
|
||||
[ -z "$1" ] && echo "send_hook: missing arg" && exit 1
|
||||
polybar-msg hook mpris-play-pause "$1" 1>/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
extract_meta() {
|
||||
grep "$1\W" <<< "$meta" | awk '{$1=$2=""; print $0}' | sed 's/^ *//; s/; */;/g' | paste -s -d/ -
|
||||
}
|
||||
|
||||
# if "icon" given, determine icon. otherwise, print metadata
|
||||
get_info() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: get_info PLAYER [icon]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
meta=$(playerctl -p "$1" metadata)
|
||||
|
||||
# get title
|
||||
title=$(extract_meta title)
|
||||
# if no title, try url e.g. vlc
|
||||
if [ -z "$title" ]; then
|
||||
title=$(extract_meta url)
|
||||
title=$(urldecode "${title##*/}")
|
||||
fi
|
||||
|
||||
# if not "icon", display information and return
|
||||
if [ "$2" != "icon" ]; then
|
||||
artist=$(extract_meta artist)
|
||||
[ -z "$artist" ] && artist=$(extract_meta albumArtist)
|
||||
|
||||
if [ -n "$artist" ]; then
|
||||
album=$(extract_meta album)
|
||||
[ -n "$album" ] && echo -n " $album "
|
||||
|
||||
echo -n " ﴁ $artist "
|
||||
fi
|
||||
|
||||
echo "$title"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# determine icon:
|
||||
# if player name is recognised, use it
|
||||
case "$1" in
|
||||
spotify* | vlc | mpv) echo "$1";;
|
||||
kdeconnect*) echo "kdeconnect";;
|
||||
chromium*)
|
||||
# if a browser, search window titles:
|
||||
|
||||
# this tries to avoid title messing up the regex
|
||||
regex_title=$(echo "$title" | tr "[:punct:]" ".")
|
||||
windowname=$(xdotool search --name --class --classname "$regex_title" getwindowname 2>/dev/null)
|
||||
case $windowname in
|
||||
"") ;; # ignore if empty
|
||||
*Netflix*) echo "netflix";;
|
||||
*YouTube*) echo "youtube";;
|
||||
*"Prime Video"*) echo "prime";;
|
||||
*"Corridor Digital"*) echo "corridor";;
|
||||
*) echo "browser";;
|
||||
esac;;
|
||||
*) echo "none";;
|
||||
esac
|
||||
}
|
||||
|
||||
# manually go through players
|
||||
read -d'\n' -ra PLAYERS <<<"$(playerctl -l 2>/dev/null)"
|
||||
declare -a PAUSED
|
||||
for player in "${PLAYERS[@]}"; do
|
||||
[ "$player" = "playerctld" ] && continue;
|
||||
|
||||
p_status=$(playerctl -p "$player" status 2>/dev/null)
|
||||
|
||||
# if we have one playing, we'll use it and EXIT
|
||||
if [ "$p_status" = "Playing" ]; then
|
||||
send_hook 1
|
||||
get_info "$player" "$2"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
[ "$p_status" = "Paused" ] && PAUSED+=("$player")
|
||||
done
|
||||
|
||||
# if we have a paused, show it otherwise assume there are no players or have all stopped
|
||||
if [ -n "${PAUSED[0]}" ]; then
|
||||
send_hook 2
|
||||
get_info "${PAUSED[0]}" "$2"
|
||||
else
|
||||
[ "$2" = icon ] && echo "none" || echo " 鈴 no players "
|
||||
fi
|
98
bin/get_mpris_status_hide_album.sh
Executable file
98
bin/get_mpris_status_hide_album.sh
Executable file
|
@ -0,0 +1,98 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The name of polybar bar which houses the main spotify module and the control modules.
|
||||
PARENT_BAR="${1:-music}"
|
||||
PARENT_BAR_PID=$(pgrep -a "polybar" | grep "$PARENT_BAR" | cut -d" " -f1)
|
||||
|
||||
urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
|
||||
|
||||
send_hook() {
|
||||
[ -z "$1" ] && echo "send_hook: missing arg" && exit 1
|
||||
polybar-msg hook mpris-play-pause "$1" 1>/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
extract_meta() {
|
||||
grep "$1\W" <<< "$meta" | awk '{$1=$2=""; print $0}' | sed 's/^ *//; s/; */;/g' | paste -s -d/ -
|
||||
}
|
||||
|
||||
# if "icon" given, determine icon. otherwise, print metadata
|
||||
get_info() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: get_info PLAYER [icon]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
meta=$(playerctl -p "$1" metadata)
|
||||
|
||||
# get title
|
||||
title=$(extract_meta title)
|
||||
# if no title, try url e.g. vlc
|
||||
if [ -z "$title" ]; then
|
||||
title=$(extract_meta url)
|
||||
title=$(urldecode "${title##*/}")
|
||||
fi
|
||||
|
||||
# if not "icon", display information and return
|
||||
if [ "$2" != "icon" ]; then
|
||||
artist=$(extract_meta artist)
|
||||
[ -z "$artist" ] && artist=$(extract_meta albumArtist)
|
||||
|
||||
if [ -n "$artist" ]; then
|
||||
album=$(extract_meta album)
|
||||
|
||||
echo -n "$artist "
|
||||
fi
|
||||
|
||||
echo "$title"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# determine icon:
|
||||
# if player name is recognised, use it
|
||||
case "$1" in
|
||||
spotify* | vlc | mpv) echo "$1";;
|
||||
kdeconnect*) echo "kdeconnect";;
|
||||
chromium*)
|
||||
# if a browser, search window titles:
|
||||
|
||||
# this tries to avoid title messing up the regex
|
||||
regex_title=$(echo "$title" | tr "[:punct:]" ".")
|
||||
windowname=$(xdotool search --name --class --classname "$regex_title" getwindowname 2>/dev/null)
|
||||
case $windowname in
|
||||
"") ;; # ignore if empty
|
||||
*Netflix*) echo "netflix";;
|
||||
*YouTube*) echo "youtube";;
|
||||
*"Prime Video"*) echo "prime";;
|
||||
*"Corridor Digital"*) echo "corridor";;
|
||||
*) echo "browser";;
|
||||
esac;;
|
||||
*) echo "none";;
|
||||
esac
|
||||
}
|
||||
|
||||
# manually go through players
|
||||
read -d'\n' -ra PLAYERS <<<"$(playerctl -l 2>/dev/null)"
|
||||
declare -a PAUSED
|
||||
for player in "${PLAYERS[@]}"; do
|
||||
[ "$player" = "playerctld" ] && continue;
|
||||
|
||||
p_status=$(playerctl -p "$player" status 2>/dev/null)
|
||||
|
||||
# if we have one playing, we'll use it and EXIT
|
||||
if [ "$p_status" = "Playing" ]; then
|
||||
send_hook 1
|
||||
get_info "$player" "$2"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
[ "$p_status" = "Paused" ] && PAUSED+=("$player")
|
||||
done
|
||||
|
||||
# if we have a paused, show it otherwise assume there are no players or have all stopped
|
||||
if [ -n "${PAUSED[0]}" ]; then
|
||||
send_hook 2
|
||||
get_info "${PAUSED[0]}" "$2"
|
||||
else
|
||||
[ "$2" = icon ] && echo "none" || echo " 鈴 no players "
|
||||
fi
|
51
bin/get_spotify_status.sh
Executable file
51
bin/get_spotify_status.sh
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The name of polybar bar which houses the main spotify module and the control modules.
|
||||
PARENT_BAR="now-playing"
|
||||
PARENT_BAR_PID=$(pgrep -a "polybar" | grep "$PARENT_BAR" | cut -d" " -f1)
|
||||
|
||||
# Set the source audio player here.
|
||||
# Players supporting the MPRIS spec are supported.
|
||||
# Examples: spotify, vlc, chrome, mpv and others.
|
||||
# Use `playerctld` to always detect the latest player.
|
||||
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
|
||||
PLAYER="playerctld"
|
||||
|
||||
# Format of the information displayed
|
||||
# Eg. {{ artist }} - {{ album }} - {{ title }}
|
||||
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
|
||||
FORMAT="{{ title }} - {{ artist }}"
|
||||
|
||||
# Sends $2 as message to all polybar PIDs that are part of $1
|
||||
update_hooks() {
|
||||
while IFS= read -r id
|
||||
do
|
||||
polybar-msg -p "$id" hook spotify-play-pause $2 1>/dev/null 2>&1
|
||||
done < <(echo "$1")
|
||||
}
|
||||
|
||||
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
STATUS=$PLAYERCTL_STATUS
|
||||
else
|
||||
STATUS="No player is running"
|
||||
fi
|
||||
|
||||
if [ "$1" == "--status" ]; then
|
||||
echo "$STATUS"
|
||||
else
|
||||
if [ "$STATUS" = "Stopped" ]; then
|
||||
echo "No music is playing"
|
||||
elif [ "$STATUS" = "Paused" ]; then
|
||||
update_hooks "$PARENT_BAR_PID" 2
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
elif [ "$STATUS" = "No player is running" ]; then
|
||||
echo "$STATUS"
|
||||
else
|
||||
update_hooks "$PARENT_BAR_PID" 1
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
fi
|
||||
fi
|
||||
|
22
bin/scroll_mpris_status.sh
Executable file
22
bin/scroll_mpris_status.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
cmd="${0%/*}/get_mpris_status.sh $1"
|
||||
|
||||
zscroll -l 50 \
|
||||
--scroll-padding "$(printf ' %.0s' {1..8})" \
|
||||
-d 0.5 \
|
||||
-M "$cmd icon" \
|
||||
-m "none" "-b ''" \
|
||||
-m "browser" "-b ' '" \
|
||||
-m "netflix" "-b 'ﱄ '" \
|
||||
-m "youtube" "-b ' '" \
|
||||
-m "prime" "-b ' '" \
|
||||
-m "spotify" "-b ' '" \
|
||||
-m "spotifyd" "-b ' '" \
|
||||
-m "vlc" "-b '嗢 '" \
|
||||
-m "mpv" "-b ' '" \
|
||||
-m "kdeconnect" "-b ' '" \
|
||||
-m "corridor" "-b ' '" \
|
||||
-U 1 -u t "$cmd" &
|
||||
|
||||
wait
|
12
bin/scroll_spotify_status.sh
Executable file
12
bin/scroll_spotify_status.sh
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
# see man zscroll for documentation of the following parameters
|
||||
zscroll -l 30 \
|
||||
--delay 0.4 \
|
||||
--match-command "`dirname $0`/get_spotify_status.sh --status" \
|
||||
--match-text "Playing" "--scroll 1" \
|
||||
--match-text "Paused" "--scroll 0" \
|
||||
--update-check true "`dirname $0`/get_spotify_status.sh" &
|
||||
|
||||
wait
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue