home/tmux: add missing scripts
This commit is contained in:
26
home/programs/tmux/scripts/fcitx5-status.sh
Executable file
26
home/programs/tmux/scripts/fcitx5-status.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p dbus
|
||||
|
||||
printState() {
|
||||
STATUS=$(dbus-send --session --print-reply=literal --dest='org.fcitx.Fcitx5' '/controller' 'org.fcitx.Fcitx.Controller1.CurrentInputMethod' | tr -d '[:space:]')
|
||||
|
||||
case $STATUS in
|
||||
keyboard-us)
|
||||
echo 'US'
|
||||
;;
|
||||
keyboard-no)
|
||||
echo 'NO'
|
||||
;;
|
||||
mozc)
|
||||
echo '日本語'
|
||||
;;
|
||||
*)
|
||||
echo "$STATUS?"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
while :; do
|
||||
printState
|
||||
sleep 1
|
||||
done
|
||||
29
home/programs/tmux/scripts/mpd-status.sh
Executable file
29
home/programs/tmux/scripts/mpd-status.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i sh -p mpc-cli gawk gnugrep
|
||||
|
||||
while true; do
|
||||
MPC_OUTPUT=$(mpc --format '[[%artist% - ]%title%]|[%file%]')
|
||||
|
||||
TITLE=$(head -n 1 <<<"$MPC_OUTPUT")
|
||||
|
||||
if [ ${#TITLE} -gt 60 ]; then
|
||||
TITLE=$(awk '{print substr($0,0,57) "..."}' <<<"$TITLE")
|
||||
fi
|
||||
|
||||
LINE2=$(head -n 2 <<<"$MPC_OUTPUT" | tail -n 1)
|
||||
|
||||
PLAY_STATUS_RAW=$(awk '{print $1}' <<<"$LINE2")
|
||||
|
||||
if [ "$PLAY_STATUS_RAW" == "[playing]" ]; then
|
||||
PLAY_STATUS="▶"
|
||||
elif [ "$PLAY_STATUS_RAW" == "[paused]" ]; then
|
||||
PLAY_STATUS="⏸"
|
||||
else
|
||||
PLAY_STATUS="??"
|
||||
fi
|
||||
|
||||
TIME=$(awk '{print $3}' <<<"$LINE2")
|
||||
|
||||
echo -e "$PLAY_STATUS $TITLE | [$TIME]"
|
||||
sleep 1
|
||||
done
|
||||
Reference in New Issue
Block a user