Created
August 29, 2016 02:45
-
-
Save khlj/8acfcef7d94db736ac228fa97357e3ca to your computer and use it in GitHub Desktop.
lemonbar gotham
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# | |
# I3 bar with https://github.com/LemonBoy/bar | |
. $(dirname $0)/i3_lemonbar_config | |
if [ $(pgrep -cx $(basename $0)) -gt 1 ] ; then | |
printf "%s\n" "The status bar is already running." >&2 | |
exit 1 | |
fi | |
trap 'trap - TERM; kill 0' INT TERM QUIT EXIT | |
[ -e "${panel_fifo}" ] && rm "${panel_fifo}" | |
mkfifo "${panel_fifo}" | |
### EVENTS METERS | |
# Window title, "WIN" | |
xprop -spy -root _NET_ACTIVE_WINDOW | sed -un 's/.*\(0x.*\)/WIN\1/p' > "${panel_fifo}" & | |
# i3 Workspaces, "WSP" | |
# TODO : Restarting I3 breaks the IPC socket con. :( | |
$(dirname $0)/i3_workspaces.pl > "${panel_fifo}" & | |
# IRC, "IRC" | |
# only for init | |
~/bin/irc_warn & | |
# Conky, "SYS" | |
conky -c $(dirname $0)/i3_lemonbar_conky > "${panel_fifo}" & | |
### UPDATE INTERVAL METERS | |
cnt_vol=${upd_vol} | |
cnt_mail=${upd_mail} | |
cnt_mpd=${upd_mpd} | |
while :; do | |
# Volume, "VOL" | |
if [ $((cnt_vol++)) -ge ${upd_vol} ]; then | |
amixer get Master | grep "${snd_cha}" | awk -F'[]%[]' '/%/ {if ($7 == "off") {print "VOL×\n"} else {printf "VOL%d%%\n", $2}}' > "${panel_fifo}" & | |
cnt_vol=0 | |
fi | |
# GMAIL, "GMA" | |
if [ $((cnt_mail++)) -ge ${upd_mail} ]; then | |
printf "%s%s\n" "GMA" "$(~/bin/gmail.sh)" > "${panel_fifo}" | |
cnt_mail=0 | |
fi | |
# MPD | |
if [ $((cnt_mpd++)) -ge ${upd_mpd} ]; then | |
#printf "%s%s\n" "MPD" "$(ncmpcpp --now-playing '{%a - %t}|{%f}' | head -c 60)" > "${panel_fifo}" | |
printf "%s%s\n" "MPD" "$(mpc current -f '[[%artist% - ]%title%]|[%file%]' 2>&1 | head -c 70)" > "${panel_fifo}" | |
cnt_mpd=0 | |
fi | |
# Finally, wait 1 second | |
sleep 1s; | |
done & | |
#### LOOP FIFO | |
cat "${panel_fifo}" | $(dirname $0)/i3_lemonbar_parser.sh \ | |
| lemonbar -p -f "${font}" -f "${iconfont}" -g "${geometry}" -B "${color_back}" -F "${color_fore}" & | |
wait | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!\bin\bash | |
# i3 panel config. Powerline style. | |
panel_fifo="/tmp/i3_lemonbar_${USER}" | |
geometry="x16" | |
font="monofur for Powerline-9" | |
iconfont="fontawesome-8" | |
# iconfont="-misc-fontawesome-medium-r-normal--0-0-0-0-p-0-iso10646-1" | |
# iconfont="-xos4-terminusicons2mono-medium-r-normal--12-120-72-72-m-60-iso8859-1" | |
# try xlsfonts | grep name | |
res_w=$(xrandr | grep "current" | awk '{print $8a}') | |
snd_cha=$(amixer get Master | grep "Playback channels:" | awk '{if ($4 == "") {printf "%s: Playback", $3} else {printf "%s %s: Playback", $3, $4}}') | |
# Alarm settings | |
cpu_alert=75 # % cpu use | |
net_alert=5 # K net use | |
# update setting, in seconds (conky update in i3_lemonbar_conky | |
upd_vol=3 # Volume update | |
upd_mail=300 # Mail check update | |
upd_mpd=5 # MPD song update | |
# color definitions | |
color_back="#FF0b0f13" # Default background | |
color_fore="#FF417c95" # Default foreground (font color) | |
color_head="#FF091f2c" # Background for first element (workspaces0 | |
color_sec_b1="#FF091f2c" # Background for section 1 (mpc, diskspace, ethernet up down, date) | |
color_sec_b2="#FF10151b" # Background for section 2 (title, cpu, mem, down, up, vol) | |
color_sec_b3="#FFffffff" # Background for section 3 | |
color_icon="#FF417c95" # For icons | |
color_mail="#FF8fb5a7" # Background color for mail alert | |
color_chat="#FFCC6666" # Background color for chat alert | |
color_cpu="#FFb52f28" # Background color for cpu alert | |
color_net="#FFb52f28" # Background color for net alert | |
color_disable="#FF959595" # Foreground for disable elements | |
color_wsp="#FF256360" # Background for selected workspace | |
color_wsicon="#FF417c95" # Color of the first icon | |
color_focusws="#FFffffff" # Color of the focused ws name | |
#default space between sections | |
if [ ${res_w} -gt 1024 ]; then | |
stab=' ' | |
else | |
stab=' ' | |
fi | |
# Char glyps for powerline fonts | |
sep_left="" # Powerline separator left | |
sep_right="" # Powerline separator right | |
sep_l_left="" # Powerline light separator left | |
sep_l_right="" # Powerline light sepatator right | |
# Icon glyphs from Terminusicons2 | |
# icon_clock="Õ" # Clock icon | |
# icon_cpu="Ï" # CPU icon | |
# icon_mem="Þ" # MEM icon | |
# icon_dl="Ð" # Download icon | |
# icon_ul="Ñ" # Upload icon | |
# icon_vol="Ô" # Volume icon | |
# icon_hd="À" # HD / icon | |
# icon_home="Æ" # HD /home icon | |
# icon_mail="Ó" # Mail icon | |
# icon_chat="Ò" # IRC/Chat icon | |
# icon_music="Î" # Music icon | |
# icon_prog="Â" # Window icon | |
# icon_contact="Á" # Contact icon | |
# icon_wsp="É" # Workspace icon | |
# Icon glyphs from font-awesome | |
icon_bat="" # Battery icon | |
icon_temp="" | |
icon_ul="" | |
icon_dl="" | |
icon_music="" | |
icon_mail="" | |
icon_vol="" | |
icon_cpu="" | |
icon_mem="" | |
icon_clock="" | |
icon_hd="" | |
icon_home="" | |
icon_prog="" | |
icon_wsp=" " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conky.config = { | |
background = false, | |
update_interval = 2, | |
total_run_times = 0, | |
override_utf8_locale = true, | |
short_units = true, | |
uppercase = false, | |
out_to_console = true, | |
out_to_x = false, | |
if_up_strictness = 'address', | |
format_human_readable = true, | |
}; | |
conky.text = [[ | |
SYS\ | |
${time %a %d %b %H:%M} \ | |
${cpu} \ | |
${mem} \ | |
${fs_used_perc /} \ | |
${fs_used_perc /home} \ | |
${if_up wlp3s0}${downspeedf wlp3s0} ${upspeedf wlp3s0} \ | |
${else}down down${endif} \ | |
${execi 300 ~/.config/yabar/scripts/bin/get_temp} \ | |
${battery_percent} \ | |
]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Input parser for i3 bar | |
# 14 ago 2015 - Electro7 | |
# config | |
. $(dirname $0)/i3_lemonbar_config | |
# min init | |
irc_n_high=0 | |
title="%{F${color_head} B${color_sec_b2}}${sep_right}%{F${color_head} B${color_sec_b2}%{T2} ${icon_prog} %{F${color_sec_b2} B-}${sep_right}%{F- B- T1}" | |
# parser | |
while read -r line ; do | |
case $line in | |
SYS*) | |
# conky=, 0 = wday, 1 = mday, 2 = month, 3 = time, 4 = cpu, 5 = mem, 6 = disk /, 7 = disk /home, 8-9 = up/down wlan, 10-11 = up/down eth, 12-13=speed | |
sys_arr=(${line#???}) | |
# date | |
if [ ${res_w} -gt 1024 ]; then | |
date="${sys_arr[0]} ${sys_arr[1]} ${sys_arr[2]}" | |
else | |
date="${sys_arr[1]} ${sys_arr[2]}" | |
fi | |
date="%{F${color_sec_b1}}${sep_left}%{F${color_icon} B${color_sec_b1}} %{T2}${icon_clock}%{F- T1} ${date}" | |
# time | |
time="%{F${color_head}}${sep_left}%{F${color_fore} B${color_head}} ${sys_arr[3]} %{F- B-}" | |
# cpu | |
if [ ${sys_arr[4]} -gt ${cpu_alert} ]; then | |
cpu_cback=${color_cpu}; cpu_cicon=${color_back}; cpu_cfore=${color_back}; | |
else | |
cpu_cback=${color_sec_b2}; cpu_cicon=${color_icon}; cpu_cfore=${color_fore}; | |
fi | |
cpu="%{F${cpu_cback}}${sep_left}%{F${cpu_cicon} B${cpu_cback}} %{T2}${icon_cpu}%{F${cpu_cfore} T1} ${sys_arr[4]}%" | |
# mem | |
mem="%{F${cpu_cicon}}${sep_l_left} %{T2}${icon_mem}%{F${cpu_cfore} T1} ${sys_arr[5]}" | |
# disk / | |
diskr="%{F${color_sec_b1}}${sep_left}%{F${color_icon} B${color_sec_b1}} %{T2}${icon_hd}%{F- T1} ${sys_arr[6]}%" | |
# disk home | |
diskh="%{F${color_icon}}${sep_l_left} %{T2}${icon_home}%{F- T1} ${sys_arr[7]}%" | |
# wlan | |
if [ "${sys_arr[8]}" == "down" ]; then | |
wland_v="×"; wlanu_v="×"; | |
wlan_cback=${color_sec_b2}; wlan_cicon=${color_disable}; wlan_cfore=${color_disable}; | |
else | |
wland_v=${sys_arr[8]}K; wlanu_v=${sys_arr[9]}K; | |
if [ ${wland_v:0:-3} -gt ${net_alert} ] || [ ${wlanu_v:0:-3} -gt ${net_alert} ]; then | |
wlan_cback=${color_net}; wlan_cicon=${color_back}; wlan_cfore=${color_back}; | |
else | |
wlan_cback=${color_sec_b2}; wlan_cicon=${color_icon}; wlan_cfore=${color_fore}; | |
fi | |
fi | |
wland="%{F${wlan_cback}}${sep_left}%{F${wlan_cicon} B${wlan_cback}} %{T2}${icon_dl}%{F${wlan_cfore} T1} ${wland_v}" | |
wlanu="%{F${wlan_cicon}}${sep_l_left} %{T2}${icon_ul}%{F${wlan_cfore} T1} ${wlanu_v}" | |
# eth | |
ethd_v=${sys_arr[10]}; ethu_v=${sys_arr[11]}%; | |
eth_cback=${color_sec_b1}; eth_cicon=${color_icon}; eth_cfore=${color_fore}; | |
ethd="%{F${eth_cback}}${sep_left}%{F${eth_cicon} B${eth_cback}} %{T2}${icon_temp}%{F${eth_cfore} T1} ${ethd_v}" | |
ethu="%{F${eth_cicon}}${sep_l_left} %{T2}${icon_bat}%{F${eth_cfore} T1} ${ethu_v}" | |
;; | |
VOL*) | |
# Volume | |
vol="%{F${color_sec_b2}}${sep_left}%{F${color_icon} B${color_sec_b2}} %{T2}${icon_vol}%{F- T1} ${line#???}" | |
;; | |
GMA*) | |
# Gmail | |
gmail="${line#???}" | |
if [ "${gmail}" != "0" ]; then | |
mail_cback=${color_mail}; mail_cicon=${color_back}; mail_cfore=${color_back} | |
else | |
mail_cback=${color_sec_b1}; mail_cicon=${color_icon}; mail_cfore=${color_fore} | |
fi | |
gmail="%{F${mail_cback}}${sep_left}%{F${mail_cicon} B${mail_cback}} %{T2}${icon_mail}%{F${mail_cfore} T1} ${gmail}" | |
;; | |
IRC*) | |
# IRC highlight (script irc_warn) | |
if [ "${line#???}" != "0" ]; then | |
((irc_n_high++)); irc_high="${line#???}"; | |
irc_cback=${color_chat}; irc_cicon=${color_back}; irc_cfore=${color_back} | |
else | |
irc_n_high=0; [ -z "${irc_high}" ] && irc_high="none"; | |
irc_cback=${color_sec_b2}; irc_cicon=${color_icon}; irc_cfore=${color_fore} | |
fi | |
irc="%{F${irc_cback}}${sep_left}%{F${irc_cicon} B${irc_cback}} %{T2}${icon_chat}%{F${irc_cfore} T1} ${irc_n_high} %{F${irc_cicon}}${sep_l_left} %{T2}${icon_contact}%{F${irc_cfore} T1} ${irc_high}" | |
;; | |
MPD*) | |
# Music | |
mpd_arr=(${line#???}) | |
if [ -z "${line#???}" ]; then | |
song="none"; | |
elif [ "${mpd_arr[0]}" == "error:" ]; then | |
song="mpd off"; | |
else | |
song="${line#???}"; | |
fi | |
mpd="%{F${color_sec_b2}}${sep_left}%{B${color_sec_b2}}%{F${color_sec_b1}}${sep_left}%{F${color_icon} B${color_sec_b1}} %{T2}${icon_music}%{F${color_fore} T1} ${song}" | |
;; | |
WSP*) | |
# I3 Workspaces | |
wsp="%{F${color_wsicon} B${color_head}} %{T2}${icon_wsp}%{T1}" | |
set -- ${line#???} | |
while [ $# -gt 0 ] ; do | |
case $1 in | |
FOC*) | |
wsp="${wsp}%{F${color_head} B${color_wsp}}${sep_right}%{F${color_focusws} B${color_wsp} T1} ${1#???} %{F${color_wsp} B${color_head}}${sep_right}" | |
;; | |
INA*|URG*|ACT*) | |
wsp="${wsp}%{F${color_disable} T1} ${1#???} " | |
;; | |
esac | |
shift | |
done | |
;; | |
WIN*) | |
# window title | |
title=$(xprop -id ${line#???} | awk '/_NET_WM_NAME/{$1=$2="";print}' | cut -d'"' -f2) | |
#title="%{F${color_head} B${color_sec_b2}}${sep_right}%{F${color_head} B${color_sec_b2}%{T2} ${icon_prog} %{F${color_sec_b2} B-}${sep_right}%{F- B- T1} ${title}" | |
title="%{F${color_head} B${color_sec_b2}}${sep_right}%{F${color_fore} B${color_sec_b2} T2} ${icon_prog} %{F${color_sec_b2} B-}${sep_right}%{F- B- T1} ${title}" | |
;; | |
esac | |
# And finally, output | |
printf "%s\n" "%{l}${wsp}${title} %{r}${mpd}${stab}${irc}${stab}${gmail}${stab}${cpu}${stab}${mem}${stab}${diskr}${stab}${diskh}${stab}${wland}${stab}${wlanu}${stab}${ethd}${stab}${ethu}${stab}${vol}${stab}${date}${stab}${time}" | |
#printf "%s\n" "%{l}${wsp}${title}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment