Commit 3da3196d authored by epsi sayidina's avatar epsi sayidina

herbstluftwm: dzen2 simple color

parent 22f14fbb
powerline-daemon -q
set POWERLINE_BASH_CONTINUATION 1
set POWERLINE_BASH_SELECT 1
set fish_function_path $fish_function_path "/usr/lib/python3.6/site-packages/powerline/bindings/fish"
powerline-setup
......@@ -34,7 +34,7 @@ sudo mkdir -p /lib/terminfo/x; sudo ln -s \
-- --
If you have trouble with xfce4-terminal, simply remove symbolic link, or any vte in /usr/local/lib generated
If you have trouble with xfce4-terminal, simply remove symbolic link, or any vte in generated /usr/local/lib .
rm /usr/local/lib/libvte-2.91.la \
/usr/local/lib/libvte-2.91.so /usr/local/lib/libvte-2.91.so.0 \
......
#!/usr/bin/env bash
# ------------------------------------------------------------------
#
# bin/chunk_cpu_usage.sh
# Description: Script for CPU usage
# feed to dzen.
#
# Source
# http://stackoverflow.com/questions/26791240/how-to-get-percentage-of-processor-use-with-bash
#
# Modified by: Epsi Nurwijayadi <epsi.nurwijayadi@gmail.com)
#
# ------------------------------------------------------------------
# $ cat /proc/stat
# - user: normal processes executing in user mode
# - nice: niced processes executing in user mode
# - system: processes executing in kernel mode
# - idle: twiddling thumbs
# - iowait: waiting for I/O to complete
# - irq: servicing interrupts
# - softirq: servicing softirqs
# - steal: involuntary wait
# - guest: running a normal guest
# - guest_nice: running a niced guest
# Read /proc/stat file (for first datapoint)
read cpu user nice system idle iowait irq softirq steal guest< /proc/stat
# compute active and total utilizations
cpu_active_prev=$((user+system+nice+softirq+steal))
cpu_total_prev=$((user+system+nice+softirq+steal+idle+iowait))
# echo 'cpu_active_prev = '.cpu_active_prev
sleep 1
# Read /proc/stat file (for second datapoint)
read cpu user nice system idle iowait irq softirq steal guest< /proc/stat
# compute active and total utilizations
cpu_active_cur=$((user+system+nice+softirq+steal))
cpu_total_cur=$((user+system+nice+softirq+steal+idle+iowait))
# compute CPU utilization (%)
cpu_util=$((100*( cpu_active_cur-cpu_active_prev ) / (cpu_total_cur-cpu_total_prev) ))
echo -n $cpu_util
exit 0
#!/usr/bin/env bash
# ------------------------------------------------------------------
#
# bin/chunk_cpu_usage.sh
# Description: Script for Download/ Upload Speed
# feed to dzen.
#
# Source
#
# Modified by: Epsi Nurwijayadi <epsi.nurwijayadi@gmail.com)
#
# ------------------------------------------------------------------
interface=$(iw dev | grep Interface | awk '{print $2}')
if [ "$interface" ]; then
# Read first datapoint
read TX_prev < /sys/class/net/$interface/statistics/tx_bytes
read RX_prev < /sys/class/net/$interface/statistics/rx_bytes
sleep 1
# Read second datapoint
read TX_curr < /sys/class/net/$interface/statistics/tx_bytes
read RX_curr < /sys/class/net/$interface/statistics/rx_bytes
# compute
TX_diff=$((TX_curr-TX_prev))
RX_diff=$((RX_curr-RX_prev))
# printout var
TX_text=$(echo "scale=1; $TX_diff/1024" | bc | awk '{printf "%.1f", $0}')
RX_text=$(echo "scale=1; $RX_diff/1024" | bc | awk '{printf "%.1f", $0}')
echo -n 'Down '$RX_text
echo -n ' Up '$TX_text
fi;
exit 0
#!/usr/bin/env bash
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# google material colors
# https://material.io/guidelines/style/color.html
colWhite='#ffffff'
colBlack='#000000'
colGrey50='#fafafa'
colGrey100='#f5f5f5'
colGrey200='#eeeeee'
colGrey300='#e0e0e0'
colGrey400='#bdbdbd'
colGrey500='#9e9e9e'
colGrey600='#757575'
colGrey700='#616161'
colGrey800='#424242'
colGrey900='#212121'
colRed50='#ffebee'
colRed100='#ffcdd2'
colRed200='#ef9a9a'
colRed300='#e57373'
colRed400='#ef5350'
colRed500='#f44336'
colRed600='#e53935'
colRed700='#d32f2f'
colRed800='#c62828'
colRed900='#b71c1c'
colRedA100='#ff8a80'
colRedA200='#ff5252'
colRedA400='#ff1744'
colRedA700='#d50000'
colBlue50='#e3f2fd'
colBlue100='#bbdefb'
colBlue200='#90caf9'
colBlue300='#64b5f6'
colBlue400='#42a5f5'
colBlue500='#2196f3'
colBlue600='#1e88e5'
colBlue700='#1976d2'
colBlue800='#1565c0'
colBlue900='#0d47a1'
colBlueA100='#82b1ff'
colBlueA200='#448aff'
colBlueA400='#2979ff'
colBlueA700='#2962ff'
colYellow50='#fffde7'
colYellow100='#fff9c4'
colYellow200='#fff59d'
colYellow300='#fff176'
colYellow400='#ffee58'
colYellow500='#ffeb3b'
colYellow600='#fdd835'
colYellow700='#fbc02d'
colYellow800='#f9a825'
colYellow900='#f57f17'
colYellowA100='#ffff8d'
colYellowA200='#ffff00'
colYellowA400='#ffea00'
colYellowA700='#ffd600'
......@@ -15,11 +15,16 @@ hc() {
# Emits a custom hook to all idling herbstclients.
hc emit_hook reload
xsetroot -solid '#5A8E3A'
# gap counter
echo 35 > /tmp/herbstluftwm-gap
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# google material colors
. ~/.config/herbstluftwm/bash/assets/gmc.sh
xsetroot -solid "$colBlue500"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# helpers
......@@ -41,8 +46,8 @@ hlc_rules
hc unlock
hc set tree_style '╾│ ├└╼─┐'
#hc set tree_style '⊙│ ├╰»─╮'
#hc set tree_style '╾│ ├└╼─┐'
hc set tree_style '⊙│ ├╰»─╮'
# do multi monitor setup here, e.g.:
# hc set_monitors 1280x1024+0+0 1280x1024+1280+0
......
......@@ -29,35 +29,48 @@
# lemonbar
# http://dotshare.it/dots/1095/
# http://dotshare.it/dots/1455/
# http://dotshare.it/dots/1444/
# http://dotshare.it/dots/1443/
# http://dotshare.it/dots/1444/ -- very cool
# http://dotshare.it/dots/1443/
# http://dotshare.it/dots/1135/
# http://dotshare.it/dots/1095/
# http://dotshare.it/dots/736/
# no bar
# http://dotshare.it/dots/623/
# unknown
# http://dotshare.it/dots/736/
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# to do
# google plus
# basedir
# awesome icon
# arrow
# bright
# lemonbar: powerline arrow, clickable, system tray
# read source
# https://github.com/herbstluftwm/herbstluftwm
# ksh
# urxvt
# lemonbar
# google plus
# panel
## * nm-applet on dzen2
# ksh --pending
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# rewrite in Perl, Python, PHP and Ruby.
#!/usr/bin/env bash
event_generator_top() {
### Event generator ###
# based on different input data (mpc, date, hlwm hooks, ...) this generates events, formed like this:
# <eventname>\t<data> [...]
# e.g.
# date ^fg(#efefef)18:33^fg(#909090), 2013-10-^fg(#efefef)29
# endless loop can be written as
# while true ; do
# or
# while :; do
# date
while :; do
# "date" output is checked once a second, but an event is only
# generated if the output changed compared to the previous run.
evDate
sleep 1 || break
done > >(uniq_linebuffered) &
date_pid=$!
# hlwm events
hc --idle
# exiting; kill stray event-emitting processes
kill $date_pid
}
event_generator_bottom() {
# player (mpd)
mpc idleloop player &
mpc_pid=$!
# batch
while true ; do
evVolume
evMemory
evDisk
evCPU
evNet
sleep 1 || break
done &
batch_pid=$!
# hlwm events
hc --idle
# exiting; kill stray event-emitting processes
kill $mpc_pid $batch_pid
}
generated_output_top() {
while true ; do
### Output ###
# This part prints dzen data based on the _previous_ data handling run,
# and then waits for the next event to happen.
# draw tags
for i in "${tags[@]}" ; do
output_by_tagmark $i
output_by_tagnumber $i
done
output_leftside_top
output_rightside_top
handle_cmd_event
done
### dzen2 ###
# After the data is gathered and processed, the output of the previous block
# gets piped to dzen2.
}
generated_output_bottom() {
while true ; do
### Output ###
# This part prints dzen data based on the _previous_ data handling run,
# and then waits for the next event to happen.
output_leftside_bottom
output_rightside_bottom
handle_cmd_event
done
### dzen2 ###
# After the data is gathered and processed, the output of the previous block
# gets piped to dzen2.
}
handle_cmd_event() {
### Data handling ###
# This part handles the events generated in the event loop, and sets
# internal variables based on them. The event and its arguments are
# read into the array cmd, then action is taken depending on the event
# name.
# "Special" events (quit_panel/togglehidepanel/reload) are also handled
# here.
# wait for next event
IFS=$'\t' read -ra cmd || break
# find out event origin
case "${cmd[0]}" in
reload)
exit
;;
quit_panel)
exit
;;
tag*)
# http://www.tldp.org/LDP/abs/html/x17837.html#HERESTRINGSREF
# echo "resetting tags" >&2
setTagValue
;;
focus_changed|window_title_changed)
setWindowtitle "${cmd[@]:2}"
;;
date)
# echo "resetting date" >&2
setDate
;;
mpd_player|player)
setMPD
;;
volume)
setVolume "${cmd[@]:1}"
;;
memory)
setMemory "${cmd[@]:1}"
;;
disk)
setDisk "${cmd[@]:1}"
;;
cpu)
setCPU "${cmd[@]:1}"
;;
net)
setNet "${cmd[@]:1}"
;;
esac
}
#!/usr/bin/env bash
tag_shows=( "一 ichi" "二 ni" "三 san" "四 shi"
"五 go" "六 roku" "七 shichi" "八 hachi" "九 kyū" "十 jū")
date=""
windowtitle=""
bordercolor="#26221C"
separator="^bg()^fg(#5c5dad)|"
nowplaying="$(mpc current -f '^fg(##c9c925)[%artist% ^fg()- ]^fg(##5c5dad)[%title%|%file%]')"
output_by_tagmark() {
$i=$1
tagmark=${i:0:1}
case $tagmark in
'#')
echo -n "^bg(#5c5dad)^fg(#ffffff)"
;;
'+')
echo -n "^bg(#9CA668)^fg(#141414)"
;;
':')
echo -n "^bg()^fg(#ffffff)"
;;
'!')
echo -n "^bg(#FF0675)^fg(#141414)"
;;
*)
echo -n "^bg()^fg(#ababab)"
;;
'#') deco="^bg($colBlue500)^fg($colWhite)" ;;
'+') deco="^bg($colYellow500)^fg($colGrey400)" ;;
':') deco="^bg()^fg($colWhite)" ;;
'!') deco="^bg($colRed500)^fg($colGrey900)" ;;
*) deco="^bg()^fg($colGrey400)" ;;
esac
echo -n $deco
}
output_by_tagnumber() {
......@@ -46,39 +28,48 @@ output_by_tagnumber() {
echo -n "use \"${i:1}\") ${key} ^ca()"
else
# non-clickable tags if using older dzen
echo -n " ${i:1} "
echo -n " ${key} "
fi
}
rightside_space() {
# small adjustments
$right=$1
right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g')
# get width of right aligned text.. and add some space..
width=$($textwidth "$font" "$right_text_only ")
echo -n "^pa($(($panel_width - $width)))"
}
output_leftside_top() {
echo -n "$separator"
left=" $separator"
left+="$segmentWindowtitle"
echo -n $left
}
output_leftside_bottom() {
echo -n "$separator"
echo -n "^bg()^fg(#c9c925) ${windowtitle//^/^^}"
left=" $separator $segmentVolume "
left+="$separator $segmentMemory "
left+="$separator $segmentDisk "
left+="$separator $segmentCPU "
left+="$separator $segmentNet "
left+="$separator "
echo -n $left
}
output_rightside_top() {
# small adjustments
right="$separator^bg() $date $separator"
right="$separator $segmentDate $separator"
right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g')
# get width of right aligned text.. and add some space..
width=$($textwidth "$font" "$right_text_only ")
echo -n "^pa($(($panel_width - $width)))$right"
rightside_space $right
echo -n $right
echo
}
output_rightside_bottom() {
# small adjustments
right="$separator^bg() $nowplaying $separator"
output_rightside_bottom() {
right=" $separator $segmentMPD "
right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g')
# get width of right aligned text.. and add some space..
width=$($textwidth "$font" "$right_text_only ")
echo -n "^pa($(($panel_width - $width)))$right"
rightside_space $right
echo -n $right
echo
}
......@@ -15,130 +15,49 @@ fi
x=${geometry[0]}
y=${geometry[1]}
panel_width=${geometry[2]}
panel_height=16
panel_height=24
bgcolor=$(hc get frame_border_normal_color)
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# google material colors
. ~/.config/herbstluftwm/bash/assets/gmc.sh
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# libraries
. ~/.config/herbstluftwm/bash/dzen2/vars.sh
. ~/.config/herbstluftwm/bash/dzen2/helper.sh
. ~/.config/herbstluftwm/bash/dzen2/segments.sh
. ~/.config/herbstluftwm/bash/dzen2/output.sh
. ~/.config/herbstluftwm/bash/dzen2/event.sh
hc pad $monitor $panel_height
event_generator_top() {
### Event generator ###
# based on different input data (mpc, date, hlwm hooks, ...) this generates events, formed like this:
# <eventname>\t<data> [...]
# e.g.
# date ^fg(#efefef)18:33^fg(#909090), 2013-10-^fg(#efefef)29
# date
while true ; do
# "date" output is checked once a second, but an event is only
# generated if the output changed compared to the previous run.
date +$'date\t^fg(#efefef)%H:%M^fg(#909090), %Y-%m-^fg(#efefef)%d'
sleep 1 || break
done > >(uniq_linebuffered) &
date_pid=$!
# hlwm events
hc --idle
# exiting; kill stray event-emitting processes
kill $date_pid
}
event_generator_bottom() {
# player (mpd)
mpc idleloop player &
mpc_pid=$!
# tick
while true; do echo tick; sleep 20; done &
tick_pid=$!
# hlwm events
hc --idle
# exiting; kill stray event-emitting processes
kill $mpc_pid $tick_pid
}
generated_output_top() {
# http://wiki.bash-hackers.org/commands/builtin/read
# http://wiki.bash-hackers.org/syntax/shellvars#ifs
IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)"
visible=true
while true ; do
### Output ###
# This part prints dzen data based on the _previous_ data handling run,
# and then waits for the next event to happen.
# draw tags
for i in "${tags[@]}" ; do
output_by_tagmark $i
output_by_tagnumber $i
done
output_leftside_top
output_rightside_top
handle_cmd_event
done
### dzen2 ###
# After the data is gathered and processed, the output of the previous block
# gets piped to dzen2.
}
generated_output_bottom() {
# http://wiki.bash-hackers.org/commands/builtin/read
# http://wiki.bash-hackers.org/syntax/shellvars#ifs
IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)"
visible=true
while true ; do
### Output ###
# This part prints dzen data based on the _previous_ data handling run,
# and then waits for the next event to happen.
output_leftside_bottom
output_rightside_bottom
handle_cmd_event
done
### dzen2 ###
# After the data is gathered and processed, the output of the previous block
# gets piped to dzen2.
}
# I don't know, but rename font to font_top, give me memory faulty with textwidth
font_default="-*-fixed-medium-*-*-*-12-*-*-*-*-*-*-*"
font_bottom="-*-terminus-bold-*-*-*-10-*-*-*-*-*-*-*"
font="-*-takaopgothic-medium-*-*-*-12-*-*-*-*-*-*-*"
#font="takaopgothic-9"
. ~/.config/herbstluftwm/bash/dzen2/generate.sh
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# Initial Value
setDate
setWindowtitle ""
setTagValue
setMPD
#setMemory
#setDisk
# do `man herbsluftclient`, and type \pad to search what it means
hc pad $monitor $panel_height 0 $panel_height 0
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# dzen Parameters
dzen2_top_parameters=" -x $x -y $y -w $panel_width -h 24"
dzen2_top_parameters+=" -fn $font"
dzen2_top_parameters+=" -ta l -bg $bgcolor -fg #efefef"
dzen2_top_parameters+=" -ta l -bg $bgcolor -fg $fgcolor"
dzen2_top_parameters+=" -title-name dzentop"
dzen2_bottom_parameters=" -x $x -y -24 -w $panel_width -h 24"
dzen2_bottom_parameters+=" -fn $font_bottom"
dzen2_bottom_parameters+=" -ta l -bg $bgcolor -fg #efefef"
dzen2_bottom_parameters+=" -ta l -bg $bgcolor -fg $fgcolor"
dzen2_bottom_parameters+=" -title-name dzenbottom"
# do `man herbsluftclient`, and \pad to search what it means
hc pad 0 24 0 24 0
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# By redirecting stderr to /dev/null, you effectively suppress these messages.
# 2> /dev/null
......
#!/usr/bin/env bash
setTagValue() {
# http://wiki.bash-hackers.org/commands/builtin/read
# http://wiki.bash-hackers.org/syntax/shellvars#ifs
# http://www.tldp.org/LDP/abs/html/x17837.html#HERESTRINGSREF
IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)"
}
evDate() {
date +$'date\t%H:%M'
}
setDate() {
segmentDate=$(date +"^fg($colGrey200)%H:%M^fg($colGrey500), %Y-%m-^fg($colGrey200)%d")
}
evVolume() {
local value=$(amixer get Master | tail -1 | sed 's/.*\[\([0-9]*%\)\].*/\1/')
echo -e "volume\t$value"
}
setVolume() {
segmentVolume="^fg($colGrey700) Vol ^fg($colBlue300)$1"
}
setWindowtitle() {
# "${segmentWindowtitle//^/^^}"
segmentWindowtitle="^bg()^fg($colYellow500) $1"
}
setMPD() {
# format="^fg(#$colYellow900)[%artist% ^fg()- ]^fg(#$colBlue500)[%title%|%file%]"
format="^fg(#$colYellow900)[%artist% ^fg()- ]^fg(#$colBlue500)[%title%]"
segmentMPD=$(mpc current -f "$format")
}
setWIFI() {
WIFI=$(iw dev | grep Interface | awk '{print $2}')
if [ \"$WIFI\" ]; then
SSID=$(iw dev $WIFI link | grep SSID: | awk '{print $2}');
fi
}
evMemory() {
local mem_total=$(free | awk 'FNR == 2 {print $2}')
local mem_used=$(free | awk 'FNR == 2 {print $3}')
local value=$[$mem_used * 100 / $mem_total]
echo -e "memory\t$value"
}
setMemory() {
segmentMemory="^fg($colGrey700) Mem ^fg($colBlue300)$1%"
}
evDisk() {
local value=$(df /home -h | awk 'FNR == 2 {print $5}' | sed s/%//)
echo -e "disk\t$value"