initial commit

This commit is contained in:
2018-03-01 00:47:14 +01:00
commit 304f883c1e
45 changed files with 2651 additions and 0 deletions

85
config/lemonbar/i3_lemonbar.sh Executable file
View File

@ -0,0 +1,85 @@
#! /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}"
# echo "=== Starting up bar at $(date +%c)" >> bar.log
### EVENTS METERS
# Window title, "WIN"
xprop -spy -root _NET_ACTIVE_WINDOW | sed -un 's/.*\(0x.*\)/WIN\1/p' > "${panel_fifo}" &
# i3 Workspaces, "WSP"
$(dirname $0)/i3_workspaces.py > ${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}
cnt_bat=${upd_bat}
cnt_win=${upd_win}
while :; do
# Volume, "VOL"
if [ $((cnt_vol++)) -ge ${upd_vol} ]; then
echo "VOL$(alsa-status)" > "${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
# Battey, "BAT"
if [ $((cnt_bat++)) -ge ${upd_bat} ]; then
echo "$(batstat)" > "${panel_fifo}" &
cnt_bat=0
fi
# Periodic Window title update (Ticket #1)
if [ $((cnt_win++)) -ge ${upd_win} ]; then
echo "WIN`mywin`" > "${panel_fifo}" &
cnt_win=0
fi
# Finally, wait 1 second
sleep 1s;
done &
#### LOOP FIFO
cat "${panel_fifo}" | $(dirname $0)/i3_lemonbar_parser.sh \
| bar -p -f "${font}" -f "${iconfont}" -f "${plfont}" -g "${geometry}" -B "${color_back}" -F "${color_fore}" &
wait

View File

@ -0,0 +1,132 @@
#!\bin\bash
# i3 panel config. Powerline style.
panel_fifo="/tmp/i3_lemonbar_${USER}"
geometry="x14"
#font="-xos4-terminesspowerline-medium-r-normal--12-120-72-72-c-60-iso10646-1"
#font="--powerlinesymbols-medium-----------"
iconfont="-wuncon-siji-medium-r-normal--10-100-75-75-c-80-iso10646-1"
res_w=$(xrandr | grep "current" | awk '{print $8a}')
# 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
upd_bat=5 # Battey update
upd_win=1 # Window title (xprop -spy only updates on focus change)
# --- APPLY XRES BEGIN
c_red_l="#ffCC6666"
c_green_l="#ffBDE077"
c_cyan_d="#ff72AD8C"
c_cursor="#fffff000"
c_yellow_d="#ffFEA63C"
c_green_d="#ffB7CE42"
c_yellow_l="#ffFFE863"
c_foreground="#ffddeedd"
c_blue_l="#ffAACCBB"
c_magenta_l="#ffff5879"
c_black_d="#ff25374A"
c_background="#ff131D24"
c_magenta_d="#ffF26B9E"
c_black_l="#ff3A526B"
c_blue_d="#ff66AABB"
c_white_l="#ffFFFFFF"
c_cyan_l="#ff9FE3BC"
c_red_d="#ffBD4A4A"
c_white_d="#ffDDEEDD"
# --- APPLY XRES END
# color definitions
color_back="$c_background" # Default background
color_fore="$c_white_l" # Default foreground
color_head="$c_yellow_d" # Background for unselected workspaces
color_wsp="$c_yellow_l" # Background for selected workspace
color_sec_b1="$c_black_d" # Background for section 1
color_sec_b2="$c_black_l" # Background for section 2
color_sec_b3="$c_white_d" # Background for section 3
color_icon="$c_white_d" # For icons
color_mail="$c_magenta_l" # Background color for mail alert
color_chat="$c_magenta_l" # Background color for chat alert
color_cpu="$c_magenta_l" # Background color for cpu alert
color_net="$c_white_l" # Background color for net alert
color_disable="$c_black_l" # Foreground for disable elements
color_clock="$c_yellow_d" # Color for clock
color_clock_edge="$c_yellow_l" # Color for clock
color_success="$c_green_d" # Positive color for good times
color_warning="$c_yellow_l" # Yellow color for warnings (eg, low battery)
color_critical="$c_magenta_l" # Red color for critical meters
#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_battery="" # Battery icon
# icon_charging="+" # Charging icon
# Icon glyphs from Siji
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_mute=""
icon_hd="À" # HD / icon
icon_home="Æ" # HD /home icon
icon_mail="Ó" # Mail icon
icon_chat="Ò" # IRC/Chat icon
icon_music="" # Music icon
icon_music_playing=""
icon_music_paused=""
icon_prog="" # Window icon
icon_contact="Á" # Contact icon
icon_wsp="" # Workspace icon
icon_battery="         "
icon_charging=""
# Ionicon glyphs
# icon_battery="" # Battery icon (half-ish full)
# icon_clock="" # Clock icon
# icon_cpu="?" # CPU icon
# icon_globe="" # Globe icon
# icon_home="" # Home icon (also linux)
# icon_laptop="" # Laptop icon
# icon_linux="" # Linux (Tux) icon
# icon_mail="" # Email icon
# icon_mem="?" # Memory icon
# icon_music="" # Music icon
# icon_paw="" # Paw icon
# icon_prog="" # Window icon
# icon_shell="" # Shell icon
# icon_vol="" # Volume icon
# icon_wsp="" # Workspace icon (paw duplicate for now)

View File

@ -0,0 +1,23 @@
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 %I:%M%p} \
${cpu} \
${mem} \
${fs_used_perc /} \
${fs_used_perc /home} \
${if_up wlp9s0}${downspeedf wlp2s0} ${upspeedf wlp2s0} \
${else} down down ${endif}\
]]

View File

@ -0,0 +1,219 @@
#!/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_clock_edge}}${sep_left}%{F${color_clock} B${color_clock_edge}}${sep_left}%{F${color_back} B${color_clock}} ${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_sec_b3}; wlan_cfore=${color_sec_b3};
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
# if [ "${sys_arr[10]}" == "down" ]; then
# ethd_v="×"; ethu_v="×";
# eth_cback=${color_sec_b1}; eth_cicon=${color_disable}; eth_cfore=${color_disable};
# else
# ethd_v=${sys_arr[10]}K; ethu_v=${sys_arr[11]}K;
# if [ ${ethd_v:0:-3} -gt ${net_alert} ] || [ ${ethu_v:0:-3} -gt ${net_alert} ]; then
# eth_cback=${color_net}; eth_cicon=${color_back}; eth_cfore=${color_back};
# else
# eth_cback=${color_sec_b1}; eth_cicon=${color_icon}; eth_cfore=${color_fore};
# fi
# fi
# ethd="%{F${eth_cback}}${sep_left}%{F${eth_cicon} B${eth_cback}} %{T2}${icon_dl}%{F${eth_cfore} T1} ${ethd_v}"
# ethu="%{F${eth_cicon}}${sep_l_left} %{T2}${icon_ul}%{F${eth_cfore} T1} ${ethu_v}"
;;
VOL*)
# Volume:
# [0] Muted indicator: (M=Muted / (anything else)=Unmuted)
# [1] On/off (muted) status (1=Unmuted / 0=Muted)
vol_arr=(${line#???})
vol_bkg=$color_sec_b2
vol_frg=$color_fore
vol_ico=$icon_vol
vol_txt=${vol_arr[1]}
if [[ ${vol_arr[0]} == "M" ]]; then
vol_bkg=$color_sec_b1
vol_frg=$color_icon
vol_ico=$icon_mute
fi
vol="%{F${vol_bkg}}${sep_left}%{F${color_icon} B${vol_bkg}} %{T2}${vol_ico}%{F${vol_frg} T1} $vol_txt%{F${color_fore}}"
;;
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[1]}" == "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}"
# echo "Setting music display to ${song}" >> bar.log
;;
BAT*)
# Battery readout:
# [0] = integer part
# [1] = charging status (D(ischarging), C(harging))
# [2] = power level (F(ull), N(ormal), L(ow), C(ritical))
bat_arr=(${line#???})
bat_icons=($icon_battery)
ico="${bat_icons[$(((${bat_arr[0]}*(${#bat_icons[@]}-1))/100))]}"
bkg="${color_sec_b1}"
frg="${color_fore}"
if [[ ${bat_arr[2]} == "L" ]]; then
bkg="${color_warning}"
frg="${color_back}"
elif [[ ${bat_arr[2]} == "C" ]]; then
bkg="${color_critical}"
frg="${color_back}"
elif [[ ${bat_arr[2]} == "F" ]]; then
bkg="${c_green_d}"
frg="${c_white_l}"
fi
batamt="%{F${bkg}}${sep_left}%{B${bkg}} %{F${frg}} ${ico} ${bat_arr[0]}%%"
if [[ ${bat_arr[1]} == "C" ]]; then
batamt="%{F${color_fore}}${sep_left}%{F${color_back} B${color_fore}}${icon_charging}${batamt}"
fi
;;
WSP*)
# I3 Workspaces
wsp="%{F${color_back} 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_back} B${color_wsp} T1} ${1##????} %{F${color_wsp} B${color_head}}${sep_right}"
;;
INA*|URG*|ACT*)
wsp="${wsp}%{F${color_back} 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} T1}${sep_right}%{F${color_icon} B${color_sec_b2} T2} ${icon_prog} %{F${color_sec_b2} B- T1}${sep_right}%{F- B- T1} ${title}"
;;
WNM*)
# Window title (string)
title=$(echo ${line#???} | xargs)
title="%{F${color_head} B${color_sec_b2} T1}${sep_right}%{F${color_icon} B${color_sec_b2} T2} ${icon_prog} %{F${color_sec_b2} B- T1}${sep_right}%{F- B- T1} ${title}"
;;
VIS*)
# Visual effects
viscmds=(${line#???})
;;
MSG*)
viscmds=(`echo "fill ${color_sec_b2} ${color_fore}"`)
msg=${line#???}
;;
WRN*)
viscmds=(`echo "fill ${color_warning} ${color_back}"`)
msg=${line#???}
;;
ALT*)
viscmds=(`echo "fill ${color_critical} ${color_back}"`)
msg=${line#???}
;;
esac
# And finally, output
if [[ ${viscmds[0]} == "fill" ]]; then
printf "%s\n" "%{l}%{B${viscmds[2]}} %{B${viscmds[1]} F${viscmds[2]}}${sep_right} ${msg} %{r}%{B${viscmds[1]} F${viscmds[2]}}"
else
printf "%s\n" "%{l}${wsp}${title} %{r}${mpd}${stab}${wland}${stab}${wlanu}${stab}${vol}${stab}${cpu}${stab}${mem}${stab}${batamt}${stab}${date}${stab}${time}"
fi
done

View File

@ -0,0 +1,138 @@
#!/usr/bin/env perl
# vim:ts=4:sw=4:expandtab:ft=perl
#
# Print i3 workspaces on every change.
#
# Format:
# For every workspace (x = workspace name)
# - "FOCx" -> Focused workspace
# - "INAx" -> Inactive workspace
# - "ACTx" -> Ative workspace
# - "URGx" -> Urgent workspace
#
# Uses AnyEvent I3 0.8 -> https://metacpan.org/module/AnyEvent::I3
# Based in i3-wsbar of Michael Stapelberg -> http://code.stapelberg.de/git/i3/tree/contrib/i3-wsbar
#
# 16 feb 2015 - Electro7
use strict;
use warnings;
use AnyEvent::I3;
use AnyEvent;
use v5.10;
my $socket_path = undef;
my ($workspaces, $outputs) = ([], {});
my $w = AnyEvent->timer(
after => 3,
cb => sub {
die "Connection to i3 timed out. Verify socket path ($socket_path)";
exit 1;
}
);
my $i3 = i3($socket_path);
# Disable buffering
$| = 1;
STDERR->autoflush;
STDOUT->autoflush;
# Wait a short amount of time and try to connect to i3 again
sub reconnect {
print "reconecting\n";
my $timer;
$i3 = i3($socket_path);
if (!defined($w)) {
$w = AnyEvent->timer(
after => 3,
cb => sub {
die "Connection to i3 timed out. Verify socket path ($socket_path)";
exit 1;
}
);
}
my $c = sub {
$timer = AnyEvent->timer(
after => 0.01,
cb => sub { $i3->connect->cb(\&connected) }
);
};
$c->();
}
# Connection attempt succeeded or failed
sub connected {
my ($cv) = @_;
if (!$cv->recv) {
reconnect();
return;
}
$w = undef;
$i3->subscribe({
workspace => \&ws_change,
output => \&output_change,
_error => sub { reconnect() }
});
ws_change();
output_change();
}
# Called when a ws changes
sub ws_change {
# Request the current workspaces and update the output afterwards
$i3->get_workspaces->cb(
sub {
my ($cv) = @_;
$workspaces = $cv->recv;
update_output();
});
}
# Called when the reply to the GET_OUTPUTS message arrives
sub got_outputs {
my $reply = shift->recv;
my %new = map { ($_->{name}, $_) } grep { $_->{active} } @{$reply};
for my $name (keys %new) {
$outputs->{$name} = $new{$name};
}
update_output();
}
sub output_change {
$i3->get_outputs->cb(\&got_outputs)
}
sub update_output {
my $out;
for my $name (keys %{$outputs}) {
$out .= "WSP";
for my $ws (@{$workspaces}) {
my $state = "INA";
$state = "ACT" if $ws->{visible};
$state = "URG" if $ws->{urgent};
$state = "FOC" if $ws->{focused};
my $name = $ws->{name};
$out .= qq|$state$name |;
}
$out .= "\n";
print $out;
}
}
$i3->connect->cb(\&connected);
# let AnyEvent do the rest ("endless loop")
AnyEvent->condvar->recv

102
config/lemonbar/i3_workspaces.py Executable file
View File

@ -0,0 +1,102 @@
#!/usr/bin/env python
#
# Print i3 workspaces on every change.
#
# Format:
# For every workspace (x = workspace name)
# - "FOCx" -> Focused workspace
# - "INAx" -> Inactive workspace
# - "ACTx" -> Ative workspace
# - "URGx" -> Urgent workspace
#
# Uses i3py.py -> https://github.com/ziberna/i3-py
# Based in wsbar.py en examples dir
#
# 16 feb 2015 - Electro7
import sys
import time
import subprocess
import i3
class State(object):
# workspace states
focused = 'FOC'
active = 'ACT'
inactive = 'INA'
urgent = 'URG'
def get_state(self, workspace, output):
if workspace['focused']:
if output['current_workspace'] == workspace['name']:
return self.focused
else:
return self.active
if workspace['urgent']:
return self.urgent
else:
return self.inactive
class i3ws(object):
ws_format = '%s%s '
end_format = 'WSP%s'
state = State()
def __init__(self, state=None):
if state:
self.state = state
# socket
self.socket = i3.Socket()
# Output to console
workspaces = self.socket.get('get_workspaces')
outputs = self.socket.get('get_outputs')
self.display(self.format(workspaces, outputs))
# Subscribe to an event
callback = lambda data, event, _: self.change(data, event)
self.subscription = i3.Subscription(callback, 'workspace')
def change(self, event, workspaces):
# Receives event and workspace data
if 'change' in event:
outputs = self.socket.get('get_outputs')
text = self.format(workspaces, outputs)
self.display(text)
def format(self, workspaces, outputs):
# Formats the text according to the workspace data given.
out = ''
for workspace in workspaces:
output = None
for output_ in outputs:
if output_['name'] == workspace['output']:
output = output_
break
if not output:
continue
st = self.state.get_state(workspace, output)
name = workspace['name']
item= self.ws_format % (st, name)
out += item
return self.end_format % out
def display(self, text):
# Displays the text in stout
print(text)
sys.stdout.flush()
def quit(self):
# Quits the i3ws; closes the subscription and terminates
self.subscription.close()
if __name__ == '__main__':
ws = i3ws()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
print('') # force new line
finally:
ws.quit()

89
config/lemonbar/lemonbar.sh Executable file
View File

@ -0,0 +1,89 @@
#! /bin/bash
#
# BSPWM 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}"
# echo "=== Starting up bar at $(date +%c)" >> bar.log
### EVENTS METERS
# Window title, "WIN"
xprop -spy -root _NET_ACTIVE_WINDOW | sed -un 's/.*\(0x.*\)/WIN\1/p' > "${panel_fifo}" &
# i3 Workspaces, "WSP"
#$(dirname $0)/i3_workspaces.py > ${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}
cnt_bat=${upd_bat}
cnt_win=${upd_win}
while :; do
# Volume, "VOL"
if [ $((cnt_vol++)) -ge ${upd_vol} ]; then
#echo "VOL$(alsa-status)" > "${panel_fifo}" &
echo "VOL20" > "${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
# Battery, "BAT"
if [ $((cnt_bat++)) -ge ${upd_bat} ]; then
#echo "$(batstat)" > "${panel_fifo}" &
echo "BAT99" > "${panel_fifo}" &
cnt_bat=0
fi
# Periodic Window title update (Ticket #1)
#if [ $((cnt_win++)) -ge ${upd_win} ]; then
#echo "WIN`mywin`" > "${panel_fifo}" &
#cnt_win=0
#fi
# Finally, wait 1 second
sleep 1s;
done &
#### LOOP FIFO
#cat "${panel_fifo}" | $(dirname $0)/i3_lemonbar_parser.sh \
#| bar -p -f "${font}" -f "${iconfont}" -f "${plfont}" -g "${geometry}" -B "${color_back}" -F "${color_fore}" &
cat "${panel_fifo}" | $(dirname $0)/i3_lemonbar_parser.sh \
| lemonbar -p -f "${font}" -f "${iconfont}" -f "${plfont}" -g "${geometry}" -B "${color_back}" -F "${color_fore}" &
wait