Commit 1e91e9a4 authored by epsi sayidina's avatar epsi sayidina

herbstluftwm: dzen2 powerline arrow

parent 3da3196d
#!/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
......@@ -33,6 +33,21 @@ colRedA200='#ff5252'
colRedA400='#ff1744'
colRedA700='#d50000'
colPink50='#fce4ec'
colPink100='#f8bbd0'
colPink200='#f48fb1'
colPink300='#f06292'
colPink400='#ec407a'
colPink500='#e91e63'
colPink600='#d81b60'
colPink700='#c2185b'
colPink800='#ad1457'
colPink900='#880e4f'
colPinkA100='#ff80ab'
colPinkA200='#ff4081'
colPinkA400='#f50057'
colPinkA700='#c51162'
colBlue50='#e3f2fd'
colBlue100='#bbdefb'
colBlue200='#90caf9'
......@@ -63,3 +78,62 @@ colYellowA200='#ffff00'
colYellowA400='#ffea00'
colYellowA700='#ffd600'
colTeal50='#e0f2f1'
colTeal100='#b2dfdb'
colTeal200='#80cbc4'
colTeal300='#4db6ac'
colTeal400='#26a69a'
colTeal500='#009688'
colTeal600='#00897b'
colTeal700='#00796b'
colTeal800='#00695c'
colTeal900='#004d40'
colTealA100='#a7ffeb'
colTealA200='#64ffda'
colTealA400='#1de9b6'
colTealA700='#00bfa5'
colGreen50='#e8f5e9'
colGreen100='#c8e6c9'
colGreen200='#a5d6a7'
colGreen300='#81c784'
colGreen400='#66bb6a'
colGreen500='#4caf50'
colGreen600='#43a047'
colGreen700='#388e3c'
colGreen800='#2e7d32'
colGreen900='#1b5e20'
colGreenA100='#b9f6ca'
colGreenA200='#69f0ae'
colGreenA400='#00e676'
colGreenA700='#00c853'
colOrange50='#fff3e0'
colOrange100='#ffe0b2'
colOrange200='#ffcc80'
colOrange300='#ffb74d'
colOrange400='#ffa726'
colOrange500='#ff9800'
colOrange600='#fb8c00'
colOrange700='#f57c00'
colOrange800='#ef6c00'
colOrange900='#e65100'
colOrangeA100='#ffd180'
colOrangeA200='#ffab40'
colOrangeA400='#ff9100'
colOrangeA700='#ff6d00'
colDeepOrange50='#fbe9e7'
colDeepOrange100='#ffccbc'
colDeepOrange200='#ffab91'
colDeepOrange300='#ff8a65'
colDeepOrange400='#ff7043'
colDeepOrange500='#ff5722'
colDeepOrange600='#f4511e'
colDeepOrange700='#e64a19'
colDeepOrange800='#d84315'
colDeepOrange900='#bf360c'
colDeepOrangeA100='#ff9e80'
colDeepOrangeA200='#ff6e40'
colDeepOrangeA400='#ff3d00'
colDeepOrangeA700='#dd2c00'
#!/usr/bin/env bash
# this is a simple config for herbstluftwm
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
hc() {
# http://www.thegeekstuff.com/2010/05/bash-shell-special-parameters/
herbstclient "$@"
}
# I don't know what it means. It might be reset or something
# emit_hook ARGS ...
# Emits a custom hook to all idling herbstclients.
hc emit_hook reload
# gap counter
echo 35 > /tmp/herbstluftwm-gap
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# google material colors
. ~/.config/herbstluftwm/bash/assets/gmc.sh
xsetroot -solid "$colBlue500"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# helpers
. ~/.config/herbstluftwm/bash/helper.sh
hlc_keybindings
hlc_tags
hlc_theme
hlc_rules
# deprecated, use nitrogen instead
# hlc_feh_wallpaper
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# unlock, just to be sure
hc unlock
#hc set tree_style '╾│ ├└╼─┐'
hc set tree_style '⊙│ ├╰»─╮'
# do multi monitor setup here, e.g.:
# hc set_monitors 1280x1024+0+0 1280x1024+1280+0
# or simply:
# hc detect_monitors
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# find the panel
panel=~/.config/herbstluftwm/bash/lemonbar/panel.sh
[ -x "$panel" ] || panel=/etc/xdg/herbstluftwm/panel.sh
for monitor in $(herbstclient list_monitors | cut -d: -f1) ; do
# start it on each monitor
"$panel" $monitor &
done
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# $ man herbstluftwm
hc lock
# tag number 5
hc floating 5 on
hc unlock
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# load on startup
if hc silent new_attr bool my_not_first_autostart ; then
. ~/.config/herbstluftwm/bash/startup.sh
fi
......@@ -49,10 +49,10 @@
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# to do
# basedir
# awesome icon
# arrow
# bright
# bright and dark
# restructure by theme
# bg fg terbalik (standarisasi penulisan)
# lemonbar: powerline arrow, clickable, system tray
......
......@@ -20,7 +20,7 @@ event_generator_top() {
evDate
sleep 1 || break
done > >(uniq_linebuffered) &
date_pid=$!
local date_pid=$!
# hlwm events
hc --idle
......@@ -33,7 +33,7 @@ event_generator_bottom() {
# player (mpd)
mpc idleloop player &
mpc_pid=$!
local mpc_pid=$!
# batch
while true ; do
......@@ -41,16 +41,27 @@ event_generator_bottom() {
evMemory
evDisk
evCPU
evSSID
evNet
evUptime
evHost
sleep 1 || break
done &
batch_pid=$!
local batch_pid=$!
# updates in
# while true ; do
# evUpdates
# sleep 1m || break
# done &
# updates_pid=$!
# hlwm events
hc --idle
# exiting; kill stray event-emitting processes
kill $mpc_pid $batch_pid
# kill $updates_pid
}
generated_output_top() {
......@@ -61,8 +72,9 @@ generated_output_top() {
# draw tags
for i in "${tags[@]}" ; do
output_by_tagmark $i
output_by_tagnumber $i
output_by_tagmark_pre $i
output_by_tagnumber $i
output_by_tagmark_post $i
done
output_leftside_top
......@@ -142,8 +154,34 @@ handle_cmd_event() {
cpu)
setCPU "${cmd[@]:1}"
;;
ssid)
setSSID "${cmd[@]:1}"
;;
net)
setNet "${cmd[@]:1}"
setNet
;;
uptime)
setUptime "${cmd[@]:1}"
;;
host)
setHost "${cmd[@]:1}"
;;
updates)
setUpdates "${cmd[@]:1}"
;;
esac
}
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# Initial Value
init_segments() {
setDate
setWindowtitle ""
setTagValue
setMPD
#setMemory
#setDisk
helperCPU
helperNet
}
This diff is collapsed.
......@@ -31,15 +31,7 @@ panel_height=24
. ~/.config/herbstluftwm/bash/dzen2/output.sh
. ~/.config/herbstluftwm/bash/dzen2/generate.sh
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# Initial Value
setDate
setWindowtitle ""
setTagValue
setMPD
#setMemory
#setDisk
init_segments
# do `man herbsluftclient`, and type \pad to search what it means
hc pad $monitor $panel_height 0 $panel_height 0
......@@ -66,5 +58,5 @@ event_generator_top 2> /dev/null | generated_output_top 2> /dev/null | dzen2 $dz
event_generator_bottom 2> /dev/null | generated_output_bottom 2> /dev/null | dzen2 $dzen2_bottom_parameters &
sleep 1 && exec `(transset-df .8 -n dzentop >/dev/null 2>&1 &)` &
sleep 1 && exec `(transset-df .8 -n dzenbottom >/dev/null 2>&1 &)` &
sleep 2 && exec `(transset-df .8 -n dzentop >/dev/null 2>&1 &)` &
......@@ -12,7 +12,30 @@ evDate() {
}
setDate() {
segmentDate=$(date +"^fg($colGrey200)%H:%M^fg($colGrey500), %Y-%m-^fg($colGrey200)%d")
local iconDate="$preIcon$postIcon"
local date=$(date +"%Y-%m")
local day=$(date +"%d")
local iconTime="$preIcon$postIcon"
local time=$(date +"%H:%M")
case $theme in
'bright-arrow')
segmentDate=" $iconTime ^fg($colGrey200)$time, "
segmentDate+="$iconDate ^fg($colGrey500)$date-^fg($colGrey200)$day"
;;
'dark-arrow')
segmentDate=" $iconTime ^fg($colGrey200)$time, "
segmentDate+="$iconDate ^fg($colGrey500)$date-^fg($colGrey200)$day"
;;
'bright-colorful')
segmentDate=" $iconTime ^fg($colGrey900)$time, "
segmentDate+="$iconDate ^fg($colGrey600)$date-^fg($colGrey900)$day"
;;
*) # 'dark-colorful'
segmentDate=" $iconTime ^fg($colGrey200)$time, "
segmentDate+="$iconDate ^fg($colGrey500)$date-^fg($colGrey200)$day"
;;
esac
}
evVolume() {
......@@ -21,26 +44,62 @@ evVolume() {
}
setVolume() {
segmentVolume="^fg($colGrey700) Vol ^fg($colBlue300)$1"
local icon="$preIcon$postIcon"
segmentVolume="$icon $labelColor Vol $valueColor$1"
}
setWindowtitle() {
setWindowtitle() {
local icon="$preIcon$postIcon"
# "${segmentWindowtitle//^/^^}"
segmentWindowtitle="^bg()^fg($colYellow500) $1"
case $theme in
'bright-arrow')
;;
'dark-arrow')
;;
'bright-colorful')
segmentWindowtitle=" $icon ^bg()^fg($colGrey700) $1"
;;
*) # 'dark-colorful'
segmentWindowtitle=" $icon ^bg()^fg($colGrey500) $1"
;;
esac
}
setMPD() {
# format="^fg(#$colYellow900)[%artist% ^fg()- ]^fg(#$colBlue500)[%title%|%file%]"
format="^fg(#$colYellow900)[%artist% ^fg()- ]^fg(#$colBlue500)[%title%]"
segmentMPD=$(mpc current -f "$format")
case $theme in
'bright-arrow')
local format="^fg(#$colGrey900)[%artist% ^fg()- ]^fg(#$colYellow500)[%title%]"
;;
'dark-arrow')
local format="^fg(#$colGrey100)[%artist% ^fg()- ]^fg(#$colYellow500)[%title%]"
;;
'bright-colorful')
local format="^fg(#$colBlue500)[%artist% ^fg()- ]^fg(#$colPink700)[%title%]"
;;
*) # 'dark-colorful'
local format="^fg(#$colBlue300)[%artist% ^fg()- ]^fg(#$colYellow500)[%title%]"
;;
esac
local iconPlay="$preIcon$postIcon"
local iconPause="$preIcon$postIcon"
segmentMPD="$iconPlay "$(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}');
evSSID() {
local wifi=$(iw dev | grep Interface | awk '{print $2}')
local value=""
if [ \"$wifi\" ]; then
value=$(iw dev $wifi link | grep SSID: | awk '{print $2 $3}')
fi
echo -e "ssid\t$value"
}
setSSID() {
local icon="$preIcon$postIcon"
segmentSSID="$icon $valueColor$1"
}
evMemory() {
......@@ -51,7 +110,8 @@ evMemory() {
}
setMemory() {
segmentMemory="^fg($colGrey700) Mem ^fg($colBlue300)$1%"
local icon="$preIcon$postIcon"
segmentMemory="$icon $labelColor Mem $valueColor$1%"
}
evDisk() {
......@@ -60,23 +120,112 @@ evDisk() {
}
setDisk() {
segmentDisk="^fg($colGrey700) Disk ^fg($colBlue300)$1%"
local icon="$preIcon$postIcon"
segmentDisk="$icon $labelColor Disk $valueColor$1%"
}
evCPU() {
local value=$(sh ~/.config/herbstluftwm/bash/assets/chunk_cpu_usage.sh)
helperCPU
local value=$cpu_util
echo -e "cpu\t$value"
}
setCPU() {
segmentCPU="^fg($colGrey700) CPU ^fg($colBlue300)$1%"
local icon="$preIcon$postIcon"
segmentCPU="$icon $labelColor CPU $valueColor$1%"
}
evNet() {
local value=$(sh ~/.config/herbstluftwm/bash/assets/chunk_net_speed.sh)
local value="$RX_text $TX_text"
echo -e "net\t$value"
}
setNet() {
segmentNet="^fg($colGrey700) Net ^fg($colBlue300)$1"
helperNet
local iconUp="$preIcon$postIcon"
local iconDown="$preIcon$postIcon"
segmentNet="$labelColor Net $iconUp $valueColor$TX_text $iconDown $valueColor$RX_text"
}
evUptime() {
local value=$(uptime -p)
echo -e "uptime\t$value"
}
setUptime() {
#  Uptime
local icon="$preIcon$postIcon"
segmentUptime="$icon $labelColor Uptime $valueColor$1"
}
evHost() {
# I prefer $(uname -r)
local value=$(uname -n)
echo -e "host\t$value"
}
setHost() {
#  Machine
#  Home
local icon="$preIcon$postIcon"
segmentHost="$icon $labelColor Host $valueColor$1"
}
evUpdates() {
local value=$(pacman -Qu | wc -l)
echo -e "updates\t$value"
}
setUpdates() {
local icon="$preIcon$postIcon"
segmentUpdates="$icon $labelColor Updates $valueColor$1"
}
helperNet() {
local 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
local TX_diff=$((TX_curr-TX_prev))
local 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}')
fi;
}
helperCPU() {
# 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
local cpu_active_prev=$((user+system+nice+softirq+steal))
local 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
local cpu_active_cur=$((user+system+nice+softirq+steal))
local 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) ))
}
......@@ -63,3 +63,27 @@ event_generator_bottom() {
# exiting; kill stray event-emitting processes
kill $mpc_pid $volume_pid $memory_pid $disk_pid $cpu_id $net_id
}
# unused
theme_leftside_bottom_left_arrow() {
local left=""
left+="^fg($colRed800)^bg($colRed900) $left_hard_arrow"
left+="^bg($colRed800)$segmentHost "
left+="^fg($colRed700)^bg($colRed800) $left_hard_arrow"
left+="^bg($colRed700)$segmentVolume "
left+="^fg($colRed600)^bg($colRed700) $left_hard_arrow"
left+="^bg($colRed600)$segmentMemory "
left+="^fg($colRed500)^bg($colRed600) $left_hard_arrow"
left+="^bg($colRed500)$segmentDisk "
left+="^fg($colRed400)^bg($colRed500) $left_hard_arrow"
left+="^bg($colRed400)$segmentCPU "
left+="^fg($colRed300)^bg($colRed400) $left_hard_arrow"
left+="^bg($colRed300)$segmentSSID "
left+="^fg($colRed200)^bg($colRed300) $left_hard_arrow"
left+="^bg($colRed200)$segmentNet "
left+="^fg($colRed100)^bg($colRed200) $left_hard_arrow"
# left+=" $segmentUpdates "
left+="^fg($colWhite)^bg($colRed100) $left_hard_arrow"
echo -n $left
}
......@@ -2,6 +2,16 @@
tag_shows=( "一 ichi" "二 ni" "三 san" "四 shi"
"五 go" "六 roku" "七 shichi" "八 hachi" "九 kyū" "十 jū")
# Four themes: [ 'dark-colorful', 'bright-colorful', 'dark-arrow', 'bright-arrow' ]
theme='dark-arrow'
# initial
if [ -z $theme ]
then
theme='dark-colorful'
fi
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# fonts
......@@ -14,9 +24,80 @@ font_bottom="-*-terminus-bold-*-*-*-10-*-*-*-*-*-*-*"
font="-*-takaopgothic-medium-*-*-*-12-*-*-*-*-*-*-*"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# colors
# dzen panel color
case $theme in
'bright-colorful' | 'bright-arrow')
bgcolor=$colWhite
fgcolor=$colBlack
;;
*) # 'dark-colorful' | 'dark-arrow'
bgcolor=$colBlack
fgcolor=$colWhite
;;
esac
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# decoration
# Powerline Symbol
right_hard_arrow="^fn(powerlinesymbols-14)^fn()"
right_soft_arrow="^fn(powerlinesymbols-14)^fn()"
left_hard_arrow="^fn(powerlinesymbols-14)^fn()"
left_soft_arrow="^fn(powerlinesymbols-14)^fn()"
# http://fontawesome.io/
FontAwesome="^fn(FontAwesome-9)"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# theme
case $theme in
'bright-arrow')
#plain
separator="^bg()^fg($colBlack)|^bg()^fg()"
preIcon="^fg($colYellow500)$FontAwesome"
postIcon="^fn()^fg()"
labelColor="^fg($colGrey300)"
valueColor="^fg($colGrey900)"
;;
'dark-arrow')
#plain
separator="^bg()^fg($colWhite)|^bg()^fg()"
preIcon="^fg($colYellow500)$FontAwesome"
postIcon="^fn()^fg()"
labelColor="^fg($colGrey900)"
valueColor="^fg($colGrey100)"
;;
'bright-colorful')
#plain
separator="^bg()^fg($colBlack)|^bg()^fg()"
preIcon="^fg($colPink700)$FontAwesome"
postIcon="^fn()^fg()"
labelColor="^fg($colGrey700)"
valueColor="^fg($colBlue700)"
;;
*) # 'dark-colorful'
#plain