commit 5da9ed8346642acd48b91a0e425d0bc3b584d42d Author: jornmann Date: Thu Apr 7 15:03:37 2022 +0300 initial commit diff --git a/candybar.sh b/candybar.sh new file mode 100755 index 0000000..0fcf2e5 --- /dev/null +++ b/candybar.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# candybar - a stupidly simple statusbar written in shell + +export bar=" " +. "$HOME/.config/candybar/config.sh" +printf "$bar\n" diff --git a/config.sh b/config.sh new file mode 100755 index 0000000..461af4e --- /dev/null +++ b/config.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# candybar configuration + +# modules location +. "$HOME/.config/candybar/modules.sh" + +# module list. uncomment to enable. +# re-arrange to change order. +# module name icon/prefix suffix +#module_mpc "MPD: " " | " +#module_uptime "Up: " " | " +#module_ram "RAM: " " | " +#module_user "User: " " | " +#module_alsa "Vol: " " | " +#module_kernel "Kernel: " " | " +#module_loadavg "Load Avg.: " " | " +#module_weather "Weather: " " | " +module_date "Date: " "" diff --git a/modules.sh b/modules.sh new file mode 100755 index 0000000..c08608b --- /dev/null +++ b/modules.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# candybar modules + +module_date() { + export bar="${bar}${1}$(date +'%a %Y-%m-%d %R')${2}" +} + +module_mpc() { + mpcoutput="$(mpc | grep -v '\[.*\]' | grep -v 'volume:')" + [ "$mpcoutput" = "" ] || export bar="${bar}${1}${mpcoutput}${2}" +} + +module_uptime() { + export bar="${bar}${1}$(uptime -p | sed 's/up // ; s/ year.*/y/ ; s/ week.*,/w/ ; s/ day.*,/d/ ; s/ hour.*,/h/ ; s/ minute.*/m/')${2}" +} + +module_ram() { + export bar="${bar}${1}$(free -h | awk '/^Mem/ { print $3"/"$2 }' | sed s/i//g)${2}" +} + +module_user() { + export bar="${bar}${1}$(whoami)@$(cat /proc/sys/kernel/hostname)${2}" +} + +module_alsa() { + export bar="${bar}${1}$(amixer sget Master | awk -F'[][]' '/Mono:/ { print $2 }')${2}" +} + +module_kernel() { + export bar="${bar}${1}$(sed "s/version // ; s/ (.*//" /proc/version)${2}" +} + +module_loadavg() { + export bar="${bar}${1}$(uptime | sed 's/.*load average: //')${2}" +} + +module_weather() { + export bar="${bar}${1}$(curl -s 'wttr.in/?format=1' | sed 's/.* //')${2}" +}