Skip to content

Instantly share code, notes, and snippets.

@anekos
Last active Jan 21, 2018
Embed
What would you like to do?
dzen2 で常時表示のステータスバー的なのを作って、コマンドで更新できるようにする
#!/bin/bash
# set -x
DZEN_OPTIONS=(-dock -x 1920 -y 0 -w 1920 -ta c -h 20 -fg 'white' -fn 'VL Gothic')
cmd="$1"
shift
fifo=~/.local/var/run/dzen-status
function cmd_daemon() {
trap clean EXIT
mkdir -p "$(dirname "$fifo")"
mkfifo "$fifo"
function clean {
rm "$fifo"
}
tail -f "$fifo" | dzen2 "${DZEN_OPTIONS[@]}"
}
function cmd_update() {
if [ ! -p "$fifo" ]
then
setsid "$0" daemon &
while [ ! -p "$fifo" ]
do
sleep 0.1
done
fi
echo "$@" >> "$fifo"
}
case "$cmd" in
daemon)
cmd_daemon
;;
update)
cmd_update "$@"
;;
*)
echo "$0 daemon"
echo "$0 update <MESSAGE>"
exit 1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment