Skip to content

Instantly share code, notes, and snippets.

@anekos
Last active January 21, 2018 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anekos/b90b7105499f80e257b63c6203ded36b to your computer and use it in GitHub Desktop.
Save anekos/b90b7105499f80e257b63c6203ded36b to your computer and use it in GitHub Desktop.
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