Commit 7b5ad369 authored by epsi sayidina's avatar epsi sayidina

dzen2: bash theming

parent a5b87d06
#!/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'
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'
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'
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
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# theme
# Four themes: [ 'dark-colorful',
# 'bright-colorful', 'dark-arrow', 'bright-arrow' ]
theme='bright-arrow'
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# include
. ~/Documents/standalone/dzen2/bash/gmc.sh
. ~/Documents/standalone/dzen2/bash/vars.sh
. ~/Documents/standalone/dzen2/bash/segments.sh
. ~/Documents/standalone/dzen2/bash/output.sh
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# main
# remove all dzen2 instance
pkill dzen2
# execute dzen
generated_output | dzen2 $parameters &
sleep 1 && exec `(transset-df .8 -n dzentop >/dev/null 2>&1 &)` &
#!/usr/bin/env bash
generated_output() {
# endless loop
while :; do
# initialize segment value
setVolume
setCPU
setMemory
setDisk
setSSID
setNet
# setUptime
# setHost
# setUpdates
# setDate
# setMPD
theme_show
echo -n $text
echo
sleep 1
done
}
#!/usr/bin/env bash
setVolume() {
local icon="$preIcon$postIcon"
local value=$(amixer get Master | tail -1 | sed 's/.*\[\([0-9]*%\)\].*/\1/')
segmentVolume="$icon $labelColor Vol $valueColor$value"
}
setMemory() {
local icon="$preIcon$postIcon"
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]
segmentMemory="$icon $labelColor Mem $valueColor$value"
}
setDisk() {
local icon="$preIcon$postIcon"
local value=$(df /home -h | awk 'FNR == 2 {print $5}' | sed s/%//)
segmentDisk="$icon $labelColor Disk $valueColor$value"
}
setCPU() {
local icon="$preIcon$postIcon"
helperCPU
local value=$cpu_util
segmentCPU="$icon $labelColor CPU $valueColor$value"
}
setSSID() {
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
local icon="$preIcon$postIcon"
segmentSSID="$icon $valueColor$value"
}
setNet() {
helperNet
local iconUp="$preIcon$postIcon"
local iconDown="$preIcon$postIcon"
segmentNet="$labelColor Net $iconUp $valueColor$TX_text $iconDown $valueColor$RX_text"
}
setUptime() {
#  Uptime
local icon="$preIcon$postIcon"
local value=$(uptime -p)
segmentUptime="$icon $labelColor Uptime $valueColor$value"
}
setHost() {
#  Machine
#  Home
local icon="$preIcon$postIcon"
# I prefer $(uname -r)
local value=$(uname -n)
segmentHost="$icon $labelColor Host $valueColor$value"
}
setUpdates() {
local icon="$preIcon$postIcon"
local value=$(pacman -Qu | wc -l)
segmentUpdates="$icon $labelColor Updates $valueColor$value"
}
setDate() {
local iconDate="$preIcon$postIcon"
local iconTime="$preIcon$postIcon"
local date=$(date +'%a %b %d')
local time=$(date +'%H:%M:%S')
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"
;;
*) # 'dark-colorful' | 'bright-colorful'
segmentDate=" $iconTime $valueColor$time, "
segmentDate+="$iconDate $valueColor$date"
;;
esac
}
setMPD() {
case $theme in
'bright-arrow')
local format="^fg(#$colGrey900)[%artist% ^fg()- ]^fg(#$colGrey300)[%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")
}
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) ))
}
#!/usr/bin/env bash
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# dzen panel parameters
bgcolor=$colWhite
fgcolor=$colBlack
alignment="l"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# theme
#plain
separator="^bg()^fg($colBlack)|^bg()^fg()"
preIcon="^fg($colYellow500)$FontAwesome"
postIcon="^fn()^fg()"
labelColor="^fg($colGrey300)"
valueColor="^fg($colGrey900)"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# dzen2 panel parts
theme_show() {
local text=""
text+=" ^bg($colRed200)^fg($colRed100)$right_hard_arrow"
text+=" $segmentVolume "
text+=" ^bg($colRed300)^fg($colRed200)$right_hard_arrow"
text+=" $segmentCPU "
text+=" ^bg($colRed400)^fg($colRed300)$right_hard_arrow"
text+=" $segmentMemory "
text+=" ^bg($colRed500)^fg($colRed400)$right_hard_arrow"
text+=" $segmentDisk "
text+=" ^bg($colRed600)^fg($colRed500)$right_hard_arrow"
text+=" $segmentSSID "
text+=" ^bg($colRed700)^fg($colRed600)$right_hard_arrow"
text+=" $segmentNet "
text+=" ^bg($colRed800)^fg($colRed700)$right_hard_arrow"
# text+=" $segmentUptime "
# text+=" $segmentHost "
# text+=" $segmentUpdates "
# text+=" $segmentDate "
# text+=" $segmentMPD "
text+=" ^bg($colWhite)^fg($colRed900)$right_hard_arrow"
text+=" "
echo -n $text
}
#!/usr/bin/env bash
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# dzen panel parameters
bgcolor=$colWhite
fgcolor=$colBlack
alignment="c"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# theme
#plain
separator="^bg()^fg($colBlack)|^bg()^fg()"
preIcon="^fg($colPink700)$FontAwesome"
postIcon="^fn()^fg()"
labelColor="^fg($colGrey700)"
valueColor="^fg($colBlue700)"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# dzen2 panel parts
. ~/Documents/standalone/dzen2/bash/themes/shared-colorful.sh
#!/usr/bin/env bash
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# dzen panel parameters
bgcolor=$colBlack
fgcolor=$colWhite
alignment="l"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# theme
#plain
separator="^bg()^fg($colWhite)|^bg()^fg()"
preIcon="^fg($colYellow500)$FontAwesome"
postIcon="^fn()^fg()"
labelColor="^fg($colGrey700)"
valueColor="^fg($colGrey300)"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# dzen2 panel parts
theme_show() {
local text=""
text+=" ^bg($colBlue200)^fg($colBlack)$right_hard_arrow"
text+=" $segmentVolume "
text+=" ^bg($colBlack)^fg($colBlue200)$right_hard_arrow"
text+=" $segmentCPU "
text+=" ^bg($colBlue400)^fg($colBlack)$right_hard_arrow"
text+=" $segmentMemory "
text+=" ^bg($colBlack)^fg($colBlue400)$right_hard_arrow"
text+=" $segmentDisk "
text+=" ^bg($colBlue600)^fg($colBlack)$right_hard_arrow"
text+=" $segmentSSID "
text+=" ^bg($colBlack)^fg($colBlue600)$right_hard_arrow"
text+=" $segmentNet "
text+=" ^bg($colBlue800)^fg($colBlack)$right_hard_arrow"
# text+=" $segmentUptime "
# text+=" $segmentHost "
# text+=" $segmentUpdates "
# text+=" $segmentDate "
# text+=" $segmentMPD "
text+=" ^bg($colBlack)^fg($colBlue900)$right_hard_arrow"
text+=" "
echo -n $text
}
#!/usr/bin/env bash
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# dzen panel parameters
bgcolor=$colBlack
fgcolor=$colWhite
alignment="c"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# theme
#plain
separator="^bg()^fg($colWhite)|^bg()^fg()"
preIcon="^fg($colYellow500)$FontAwesome"
postIcon="^fn()^fg()"
labelColor="^fg($colGrey700)"
valueColor="^fg($colBlue300)"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# dzen2 panel parts
. ~/Documents/standalone/dzen2/bash/themes/shared-colorful.sh
#!/usr/bin/env bash
theme_show() {
local text=""
text+="$separator $segmentVolume "
text+="$separator $segmentCPU "
text+="$separator $segmentMemory "
text+="$separator $segmentDisk "
text+="$separator $segmentSSID "
text+="$separator $segmentNet "
# text+="$separator $segmentUptime "
# text+="$separator $segmentHost "
# text+="$separator $segmentUpdates "
# text+="$separator $segmentDate "
# text+="$separator $segmentMPD "
text+="$separator "
echo -n $text
}
#!/usr/bin/env bash
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# fonts
# I don't know, but rename font to font_top, give me memory faulty with textwidth
# https://en.wikipedia.org/wiki/X_logical_font_description
# https://wiki.archlinux.org/index.php/X_Logical_Font_Description
font="-*-fixed-medium-*-*-*-12-*-*-*-*-*-*-*"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# 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
# Four themes: [ 'dark-colorful',
# 'bright-colorful', 'dark-arrow', 'bright-arrow' ]
# initial
if [ -z $theme ]
then
theme='dark-colorful'
# dzen panel color
bgcolor=$colBlack
fgcolor=$colWhite
alignment="c"
fi
init_theme() {
theme_config_default=~/Documents/standalone/dzen2/bash/themes/dark-colorful.sh
theme_config=~/Documents/standalone/dzen2/bash/themes/${theme}.sh
[ -x "$theme_config" ] || theme_config=$theme_config_default
. $theme_config
}
init_theme
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# dzen2 parameters
xpos=0
ypos=0
width=640
height=24
font="-*-fixed-medium-*-*-*-12-*-*-*-*-*-*-*"
parameters=" -x $xpos -y $ypos -w $width -h $height"
parameters+=" -fn $font"
parameters+=" -ta $alignment -bg $bgcolor -fg $fgcolor"
parameters+=" -title-name dzentop"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment