Commit feae0ccf authored by epsi sayidina's avatar epsi sayidina
Browse files

herbstluftwm tags with lemonbar

parent d0d24b0c
......@@ -35,18 +35,22 @@ set_tags_with_name
# do hash config
# hack associative array function argument passing using declare -p
do_config "keybind" "$(declare -p keybinds)"
do_config "keybind" "$(declare -p tagskeybinds)"
do_config "mousebind" "$(declare -p mousebinds)"
do_config "attr" "$(declare -p attributes)"
do_config "set" "$(declare -p sets)"
do_config "rule" "$(declare -p rules)"
do_config 'keybind' "$(declare -p keybinds)"
do_config 'keybind' "$(declare -p tagskeybinds)"
do_config 'mousebind' "$(declare -p mousebinds)"
do_config 'attr' "$(declare -p attributes)"
do_config 'set' "$(declare -p sets)"
do_config 'rule' "$(declare -p rules)"
# avoid tilde problem, not using helper
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' pseudotile=on
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# finishing, some extra miles
# I'm not sure what in this is
bind_cycle_layout
#bind_cycle_layout
# example of custom layout
layout='(split horizontal:0.5:0 '
......
......@@ -174,8 +174,8 @@ declare -A rules=(
["class~'(.*[Rr]xvt.*|.*[Tt]erm|Konsole)'"]='focus=on'
["windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)'"]='pseudotile=on'
# ["windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)'"]='pseudotile=on'
# ["windowtype='_NET_WM_WINDOW_TYPE_DIALOG'"]='focus=on'
["windowtype='_NET_WM_WINDOW_TYPE_DIALOG'"]='fullscreen=on'
["windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)'"]='manage=off'
# ["windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)'"]='manage=off'
)
......@@ -23,11 +23,11 @@ right_soft_arrow="^fn(powerlinesymbols-14)^fn()"
left_soft_arrow="^fn(powerlinesymbols-14)^fn()"
# http://fontawesome.io/
FontAwesome="^fn(FontAwesome-9)"
font_awesome="^fn(FontAwesome-9)"
# theme
preIcon="^fg(${color['yellow500']})$FontAwesome"
postIcon="^fn()^fg()"
pre_icon="^fg(${color['yellow500']})$font_awesome"
post_icon="^fn()^fg()"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# main
......@@ -65,8 +65,7 @@ function output_by_tag() {
local text_pre=''
case $tag_mark in
'#')
text_pre+="^bg(${color['blue500']})^fg(${color['black']})"
'#') text_pre+="^bg(${color['blue500']})^fg(${color['black']})"
text_pre+=$right_hard_arrow
text_pre+="^bg(${color['blue500']})^fg(${color['white']})"
;;
......@@ -118,7 +117,7 @@ function set_tag_value() {
function set_windowtitle() {
local windowtitle=$1
local icon="$preIcon$postIcon"
local icon="$pre_icon$post_icon"
# "${segmentWindowtitle//^/^^}"
segment_windowtitle=" $icon ^bg()^fg(${color['grey700']}) $windowtitle"
......
......@@ -9,7 +9,7 @@ function handle_command_event() {
local event=$@
# find out event origin
IFS=' ' read -r -a column <<< "$event"
IFS=$'\t' column=($event);
origin=${column[0]}
# find out event origin
......
......@@ -45,7 +45,7 @@ def get_dzen2_parameters(monitor, panel_height):
font = '-*-takaopgothic-medium-*-*-*-12-*-*-*-*-*-*-*'
parameters = ' -x '+str(xpos)+' -y '+str(ypos) \
+ ' -w '+str(width)+' -h '+ str(height) \
+ ' -w '+str(width)+' -h '+str(height) \
+ " -fn '"+font+"'" \
+ " -ta l -bg '"+bgcolor+"' -fg '"+fgcolor+"'" \
+ ' -title-name dzentop'
......
#!/usr/bin/env bash
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# google material colors
# https://material.io/guidelines/style/color.html
# Associative Array (Hash)
declare -A color=(
['white']='#ffffff'
['black']='#000000'
['grey50']='#fafafa'
['grey100']='#f5f5f5'
['grey200']='#eeeeee'
['grey300']='#e0e0e0'
['grey400']='#bdbdbd'
['grey500']='#9e9e9e'
['grey600']='#757575'
['grey700']='#616161'
['grey800']='#424242'
['grey900']='#212121'
['red50']='#ffebee'
['red100']='#ffcdd2'
['red200']='#ef9a9a'
['red300']='#e57373'
['red400']='#ef5350'
['red500']='#f44336'
['red600']='#e53935'
['red700']='#d32f2f'
['red800']='#c62828'
['red900']='#b71c1c'
['redA100']='#ff8a80'
['redA200']='#ff5252'
['redA400']='#ff1744'
['redA700']='#d50000'
['pink50']='#fce4ec'
['pink100']='#f8bbd0'
['pink200']='#f48fb1'
['pink300']='#f06292'
['pink400']='#ec407a'
['pink500']='#e91e63'
['pink600']='#d81b60'
['pink700']='#c2185b'
['pink800']='#ad1457'
['pink900']='#880e4f'
['pinkA100']='#ff80ab'
['pinkA200']='#ff4081'
['pinkA400']='#f50057'
['pinkA700']='#c51162'
['blue50']='#e3f2fd'
['blue100']='#bbdefb'
['blue200']='#90caf9'
['blue300']='#64b5f6'
['blue400']='#42a5f5'
['blue500']='#2196f3'
['blue600']='#1e88e5'
['blue700']='#1976d2'
['blue800']='#1565c0'
['blue900']='#0d47a1'
['blueA100']='#82b1ff'
['blueA200']='#448aff'
['blueA400']='#2979ff'
['blueA700']='#2962ff'
['yellow50']='#fffde7'
['yellow100']='#fff9c4'
['yellow200']='#fff59d'
['yellow300']='#fff176'
['yellow400']='#ffee58'
['yellow500']='#ffeb3b'
['yellow600']='#fdd835'
['yellow700']='#fbc02d'
['yellow800']='#f9a825'
['yellow900']='#f57f17'
['yellowA100']='#ffff8d'
['yellowA200']='#ffff00'
['yellowA400']='#ffea00'
['yellowA700']='#ffd600'
['teal50']='#e0f2f1'
['teal100']='#b2dfdb'
['teal200']='#80cbc4'
['teal300']='#4db6ac'
['teal400']='#26a69a'
['teal500']='#009688'
['teal600']='#00897b'
['teal700']='#00796b'
['teal800']='#00695c'
['teal900']='#004d40'
['tealA100']='#a7ffeb'
['tealA200']='#64ffda'
['tealA400']='#1de9b6'
['tealA700']='#00bfa5'
['green50']='#e8f5e9'
['green100']='#c8e6c9'
['green200']='#a5d6a7'
['green300']='#81c784'
['green400']='#66bb6a'
['green500']='#4caf50'
['green600']='#43a047'
['green700']='#388e3c'
['green800']='#2e7d32'
['green900']='#1b5e20'
['greenA100']='#b9f6ca'
['greenA200']='#69f0ae'
['greenA400']='#00e676'
['greenA700']='#00c853'
['orange50']='#fff3e0'
['orange100']='#ffe0b2'
['orange200']='#ffcc80'
['orange300']='#ffb74d'
['orange400']='#ffa726'
['orange500']='#ff9800'
['orange600']='#fb8c00'
['orange700']='#f57c00'
['orange800']='#ef6c00'
['orange900']='#e65100'
['orangeA100']='#ffd180'
['orangeA200']='#ffab40'
['orangeA400']='#ff9100'
['orangeA700']='#ff6d00'
['deepOrange50']='#fbe9e7'
['deepOrange100']='#ffccbc'
['deepOrange200']='#ffab91'
['deepOrange300']='#ff8a65'
['deepOrange400']='#ff7043'
['deepOrange500']='#ff5722'
['deepOrange600']='#f4511e'
['deepOrange700']='#e64a19'
['deepOrange800']='#d84315'
['deepOrange900']='#bf360c'
['deepOrangeA100']='#ff9e80'
['deepOrangeA200']='#ff6e40'
['deepOrangeA400']='#ff3d00'
['deepOrangeA700']='#dd2c00'
)
#!/usr/bin/env bash
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# helpers
# script arguments
function get_monitor() {
local argument=("$@")
local num_args=${#argument[@]}
# ternary operator
[[ $num_args > 0 ]] && monitor=${argument[0]} || monitor=0
}
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# geometry calculation
function get_geometry() {
local monitor=$1;
geometry=( $(herbstclient monitor_rect "$monitor") )
if [ -z "$geometry" ] ;then
echo "Invalid monitor $monitor"
exit 1
fi
}
function get_top_panel_geometry() {
local panel_height=$1
shift
local geometry=("$@")
# geometry has the format X Y W H
xpos=${geometry[0]}
ypos=${geometry[1]}
width=${geometry[2]}
height=$panel_height
}
function get_bottom_panel_geometry() {
local panel_height=$1
shift
local geometry=("$@")
# geometry has the format X Y W H
xpos=${geometry[0]}
ypos=${geometry[3]}-$panel_height
width=${geometry[2]}
height=$panel_height
}
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# lemonbar Parameters
function get_lemon_parameters() {
# parameter: function argument
local monitor=$1
local panel_height=$2
# calculate geometry
get_geometry $monitor
get_top_panel_geometry $panel_height "${geometry[@]}"
# geometry: -g widthxheight+x+y
g_res="${width}x${height}+${xpos}+${ypos}"
# color, with transparency
local bgcolor="#aa000000"
local fgcolor="#ffffff"
# XFT: require lemonbar_xft_git
local font_takaop="takaopgothic-9"
local font_bottom="monospace-9"
local font_symbol="PowerlineSymbols-11"
local font_awesome="FontAwesome-9"
# finally
lemon_parameters=" -g $g_res -u 2"
lemon_parameters+=" -B $bgcolor -F $fgcolor"
lemon_parameters+=" -f $font_takaop -f $font_awesome -f $font_symbol"
}
#!/usr/bin/env bash
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# initialize
# custom tag names
tag_shows=( "一 ichi" "二 ni" "三 san" "四 shi"
"五 go" "六 roku" "七 shichi" "八 hachi" "九 kyū" "十 jū")
# initialize variable segment
segment_windowtitle='';
tags_status=(); # empty array
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# decoration
separator="%{B-}%{F${color['yellow500']}}|%{B-}%{F-}"
# Powerline Symbol
right_hard_arrow=""
right_soft_arrow=""
left_hard_arrow=""
left_soft_arrow=""
# theme
pre_icon="%{F${color['yellow500']}}"
post_icon="%{F-}"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# main
function get_statusbar_text() {
local monitor=$1
local text=''
# draw tags
text+='%{l}'
for tag_status in "${tags_status[@]}"
do
output_by_tag $monitor $tag_status
text+=$buffer
done
# draw window title
text+='%{r}'
output_leftside_top
text+=$buffer
buffer=$text
}
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# each segments
function output_by_tag() {
local monitor=$1
local tag_status=$2
local tag_index=${tag_status:1:1}
local tag_mark=${tag_status:0:1}
local tag_name=${tag_shows[$tag_index - 1]}; # zero based
# ----- pre tag
local text_pre=''
case $tag_mark in
'#') text_pre+="%{B${color['blue500']}}%{F${color['black']}}"
text_pre+="%{U${color['white']}}%{+u}$right_hard_arrow"
text_pre+="%{B${color['blue500']}}%{F${color['white']}}"
text_pre+="%{U${color['white']}}%{+u}"
;;
'+') text_pre+="%{B${color['yellow500']}}%{F${color['grey400']}}"
;;
':') text_pre+="%{B-}%{F${color['white']}}"
text_pre+="%{U${color['red500']}}%{+u}"
;;
'!') text_pre+="%{B${color['red500']}}%{F${color['white']}}"
text_pre+="%{U${color['white']}}%{+u}"
;;
*) text_pre+="%{B-}%{F${color['grey600']}}%{-u}"
;;
esac
# ----- tag by number
# non clickable tags
local text_name=" $tag_name "
# ----- post tag
local text_post=''
if [ $tag_mark = '#' ]
then
text_post+="%{B-}%{F${color['blue500']}}"
text_post+="%{U${color['red500']}}%{+u}${right_hard_arrow}";
fi
text_post+='%{B-}%{F-}%{-u}'
buffer="$text_pre$text_name$text_post"
}
function output_leftside_top() {
local text="$segment_windowtitle $separator "
buffer=$text
}
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# setting variables, response to event handler
function set_tag_value() {
# 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_status <<< "$(herbstclient tag_status $monitor)"
}
function set_windowtitle() {
local windowtitle=$1
local icon="$pre_icon$post_icon"
# "${segmentWindowtitle//^/^^}"
segment_windowtitle=" $icon %{B-}%{F${color['grey700']}} $windowtitle"
}
#!/usr/bin/env bash
# This is a modularized config for herbstluftwm tags in dzen2 statusbar
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# libraries
DIR=$(dirname "$0")
. ${DIR}/gmc.sh
. ${DIR}/helper.sh
. ${DIR}/output.sh
. ${DIR}/pipehandler.sh
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# initialize
panel_height=24
get_monitor ${@}
# do `man herbsluftclient`, and type \pad to search what it means
herbstclient pad $monitor $panel_height 0 $panel_height 0
get_lemon_parameters $monitor $panel_height
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# pipe
# remove all lemonbar instance
pkill lemonbar
# run process in the background
detach_lemon $monitor $lemon_parameters
#!/usr/bin/env bash
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# pipe
function handle_command_event() {
local monitor=$1
shift
local event=$@
# find out event origin
IFS=$'\t' column=($event);
origin=${column[0]}
# find out event origin
case $origin in
reload)
pkill lemonbar
;;
quit_panel)
exit
;;
tag*)
# http://www.tldp.org/LDP/abs/html/x17837.html#HERESTRINGSREF
# echo "resetting tags" >&2
set_tag_value $monitor
;;
focus_changed|window_title_changed)
set_windowtitle "${column[2]}"
;;
esac
}
function init_content() {
monitor=$1
# initialize statusbar before loop
set_tag_value $monitor
set_windowtitle ''
get_statusbar_text $monitor
echo $buffer
}
function walk_content() {
monitor=$1
# start a pipe
command_in='herbstclient --idle'
# wait for each event
$command_in | while read event; do
handle_command_event $monitor "$event"
get_statusbar_text $monitor
echo $buffer
done
}
function run_lemon() {
monitor=$1
shift
parameters=$@
command_out="lemonbar $parameters"
{
init_content $monitor
walk_content $monitor # loop for each event
} | $command_out
}
function detach_lemon() {
monitor=$1
shift
parameters=$@
run_lemon $monitor $parameters &
}
package gmc;
use warnings;
use strict;
use Exporter;
our @ISA = 'Exporter';
our @EXPORT = qw(%color);
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# google material colors
# https://material.io/guidelines/style/color.html
# Associative Array (Hash)
our %color = (
'white' => '#ffffff',
'black' => '#000000',
'grey50' => '#fafafa',
'grey100' => '#f5f5f5',
'grey200' => '#eeeeee',
'grey300' => '#e0e0e0',
'grey400' => '#bdbdbd',
'grey500' => '#9e9e9e',
'grey600' => '#757575',
'grey700' => '#616161',
'grey800' => '#424242',
'grey900' => '#212121',
'red50' => '#ffebee',
'red100' => '#ffcdd2',
'red200' => '#ef9a9a',
'red300' => '#e57373',
'red400' => '#ef5350',
'red500' => '#f44336',
'red600' => '#e53935',
'red700' => '#d32f2f',
'red800' => '#c62828',
'red900' => '#b71c1c',
'redA100' => '#ff8a80',
'redA200' => '#ff5252',
'redA400' => '#ff1744',
'redA700' => '#d50000',
'pink50' => '#fce4ec',
'pink100' => '#f8bbd0',
'pink200' => '#f48fb1',
'pink300' => '#f06292',
'pink400' => '#ec407a',
'pink500' => '#e91e63',