Skip to content

Instantly share code, notes, and snippets.

@bake
Last active November 19, 2015 01:09
Show Gist options
  • Save bake/19cc43cfb1e7d9806493 to your computer and use it in GitHub Desktop.
Save bake/19cc43cfb1e7d9806493 to your computer and use it in GitHub Desktop.
i3 workspace indicators in lemonbar
#!/usr/bin/fish
set normal '%{F#ffffff}'
set urgent '%{F#e8586e}'
set good '%{F#00ff00}'
set inactive '%{F#616161}'
set separator $inactive' / '$normal
function workspace
set -l length (i3-msg -t get_workspaces | jq -r '. | length')
for i in (seq $length)
set -l workspace (i3-msg -t get_workspaces | jq -j '.['(math $i - 1)']')
if [ (echo $workspace | jq -r '.urgent') = 'true' ]
echo -n $urgent
else if [ (echo $workspace | jq -r '.focused') != 'true' ]
echo -n $inactive
end
echo -n (echo $workspace | jq -r '.name' | cut -c 3-)
echo -n '%{F-} '
end
end
function battery
set now (cat /sys/class/power_supply/BAT*/charge_now)
set full (cat /sys/class/power_supply/BAT*/charge_full)
set percent (math 100'*'$now'/'$full)
if [ (cat /sys/class/power_supply/BAT*/status) = 'Charging' ]
echo -n $good
else if [ $percent -lt 10 ]
echo -n $urgent
end
echo -n $percent'%'
end
function wifi
set -l network (iwgetid -r)
if [ $network ]
echo -n $network
end
end
function ipv4
echo -n (ip addr | grep 'inet ' | grep -v '127.0.0.1' | awk '{ print $2}')
end
function time
date '+%a %b %d, %H:%M'
end
while true
echo -n '%{l}%{F-}'
echo -n ' '(workspace)
echo -n '%{c}%{F-}'(time)
echo -n '%{r}%{F-}'(battery)$separator(wifi)' ('(ipv4)')'
echo ' '
sleep .5
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment