generation 487 25.11.20250714.62e0f05
This commit is contained in:
86
home/scripts/music/cmus-status.sh
Normal file
86
home/scripts/music/cmus-status.sh
Normal file
@@ -0,0 +1,86 @@
|
||||
#
|
||||
is_valid_utf8() {
|
||||
local input="$1"
|
||||
local converted=$(echo -n "$input" | iconv -f utf-8 -t utf-16 | iconv -f utf-16 -t utf-8)
|
||||
[[ "$input" == "$converted" ]] && return 0 || return 1
|
||||
}
|
||||
|
||||
# if cmus or spotify isn't running, this exit will trigger
|
||||
er="$(cmus-remote -Q 2> /dev/null)"
|
||||
eq="$(playerctl --player=spotify status 2> /dev/null)"
|
||||
if [ "$er" == "" ] && [ "$eq" == "" ] ;then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#sspot="$()"
|
||||
#if [[ "$eq" == "Paused" ]];then
|
||||
|
||||
if [[ "$eq" != "" ]]; then
|
||||
stitle="$(playerctl --player=spotify metadata --format "{{ title }}" 2> /dev/null)"
|
||||
sartist="$(playerctl --player=spotify metadata --format "{{ artist }}" 2> /dev/null)"
|
||||
|
||||
if [ ${#sartist} -gt 13 ]; then
|
||||
sartist="${sartist:0:$((13))}.."
|
||||
fi
|
||||
|
||||
if [ ${#stitle} -gt 20 ]; then
|
||||
stitle="${stitle:0:$((20))}.."
|
||||
fi
|
||||
|
||||
soutput="$sartist — $stitle"
|
||||
rb=""
|
||||
if [[ "$eq" == "Paused" ]]; then
|
||||
rb="| ";
|
||||
elif [[ "$eq" == "Playing" ]]; then
|
||||
rb="> ";
|
||||
fi
|
||||
soutput="${rb}${soutput}"
|
||||
|
||||
if is_valid_utf8 "$soutput"; then
|
||||
echo "$soutput"
|
||||
else
|
||||
echo "not UTF-8 :("
|
||||
fi
|
||||
|
||||
echo "$soutput"
|
||||
elif [[ "$er" != "" ]]; then
|
||||
# if cmus isn't currently playing a song, this will trigger
|
||||
artist="$(cmus-remote -Q 2> /dev/null | awk -F"tag artist " '{print $2}' | tr -d '\n')"
|
||||
if [[ "$artist" == "false" ]] ;then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
title="$( cmus-remote -Q 2> /dev/null | awk -F"tag title " '{print $2}' | tr -d '\n')"
|
||||
|
||||
if [ ${#artist} -gt 13 ]; then
|
||||
artist="${artist:0:$((13))}.."
|
||||
fi
|
||||
|
||||
if [ ${#title} -gt 20 ]; then
|
||||
title="${title:0:$((20))}.."
|
||||
fi
|
||||
|
||||
ss="$(cmus-remote -Q 2> /dev/null| awk -F/ NR==1'{print $NF}'|awk -F. '{print $1}')"
|
||||
|
||||
output="$artist — $title"
|
||||
scroll_length=30
|
||||
|
||||
# if not playing
|
||||
if [[ "$ss" != "status playing" ]]; then
|
||||
# to be completed..
|
||||
r="| "
|
||||
output="${r}${output}"
|
||||
# if is playing
|
||||
else
|
||||
r="> "
|
||||
output="${r}${output}"
|
||||
fi
|
||||
|
||||
if is_valid_utf8 "$output"; then
|
||||
echo "$output"
|
||||
else
|
||||
echo "not UTF-8 :("
|
||||
fi
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
24
home/scripts/pomodoro.sh
Normal file
24
home/scripts/pomodoro.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
state="$(qdbus org.gnome.Pomodoro /org/gnome/Pomodoro org.freedesktop.DBus.Properties.Get org.gnome.Pomodoro State)"
|
||||
if [ "$state" == "null" ]; then
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elapsed=$(qdbus org.gnome.Pomodoro /org/gnome/Pomodoro org.freedesktop.DBus.Properties.Get org.gnome.Pomodoro Elapsed)
|
||||
state_duration=$(qdbus org.gnome.Pomodoro /org/gnome/Pomodoro org.freedesktop.DBus.Properties.Get org.gnome.Pomodoro StateDuration)
|
||||
|
||||
remaining=$(echo "$state_duration - $elapsed" | bc)
|
||||
|
||||
# Format the remaining time as minutes:seconds
|
||||
minutes=$(echo "$remaining / 60" | bc)
|
||||
seconds=$(echo "$remaining % 60" | bc)
|
||||
|
||||
# Pad seconds with leading zero if necessary
|
||||
printf -v seconds "%02d" $seconds 2> /dev/null
|
||||
|
||||
if [ "$state" == "short-break" ]; then
|
||||
state="break"
|
||||
fi
|
||||
|
||||
echo "$state - $minutes:$seconds"
|
||||
|
||||
Reference in New Issue
Block a user