Commit 345cb4d6 authored by epsi sayidina's avatar epsi sayidina

herbstluftwm tags test

parent e9ef831a
......@@ -28,7 +28,7 @@ hc('keyunbind --all');
hc("mouseunbind --all");
hc("unrule -F");
set_tags_with_name($tag_names, $tag_keys);
set_tags_with_name();
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# do hash config
......
......@@ -21,10 +21,10 @@ function do_config($command, $hash) {
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# tags related
# Must pass the array as parameters,
# since PHP can't read local array variable outside function.
function set_tags_with_name($tag_names, $tag_keys)
function set_tags_with_name()
{
global $tag_names, $tag_keys;
hc("rename default '$tag_names[0]' 2>/dev/null || true");
foreach($tag_names as $index=>$value) {
......
#!/usr/bin/env bash
content() {
while true ; do
statusbar_text
handle_cmd_event
done
### dzen2 ###
# After the data is gathered and processed, the output of the previous block
# gets piped to dzen2.
}
statusbar_text() {
### Output ###
# This part prints dzen data based on the _previous_ data handling run,
# and then waits for the next event to happen.
text=''
# draw tags
for i in "${tags[@]}" ; do
text+=$(output_by_tagmark_pre $i)
text+=$(output_by_tagnumber $i)
text+=$(output_by_tagmark_post $i)
done
text+=$(output_leftside_top)
echo $text
}
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)
pkill dzen2
exit
;;
quit_panel)
exit
;;
tag*)
# http://www.tldp.org/LDP/abs/html/x17837.html#HERESTRINGSREF
# echo "resetting tags" >&2
set_tag_value
;;
focus_changed|window_title_changed)
set_windowtitle "${cmd[@]:2}"
;;
esac
}
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# Initial Value
init_segments() {
set_windowtitle ""
set_tag_value
}
#!/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() {
monitor=${1:-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=("[email protected]")
# 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=("[email protected]")
# geometry has the format X Y W H
xpos=${geometry[0]}
ypos=${geometry[3]}-$panel_height
width=${geometry[2]}
height=$panel_height
}
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# dzen Parameters
function get_dzen2_parameters() {
local monitor=$1
local panel_height=$2
get_geometry $monitor
get_top_panel_geometry $panel_height "${geometry[@]}"
bgcolor="#000000"
fgcolor="#ffffff"
font="-*-takaopgothic-medium-*-*-*-12-*-*-*-*-*-*-*"
dzen2_parameters=" -x $xpos -y $ypos -w $width -h $height"
dzen2_parameters+=" -fn $font"
dzen2_parameters+=" -ta l -bg $bgcolor -fg $fgcolor"
dzen2_parameters+=" -title-name dzentop"
}
#!/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="^bg()^fg(${color['black']})|^bg()^fg()"
# 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
preIcon="^fg(${color['yellow500']})$FontAwesome"
postIcon="^fn()^fg()"
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# dzen2 panel parts
output_by_tagmark_pre() {
$i=$1
local tagmark=${i:0:1}
local deco=""
case $tagmark in
'#')
deco+="^bg(${color['blue500']})^fg(${color['black']})"
deco+=$right_hard_arrow
deco+="^bg(${color['blue500']})^fg(${color['white']})"
;;
'+') deco+="^bg(${color['yellow500']})^fg(${color['grey400']})"
;;
':') deco+="^bg()^fg(${color['white']})"
;;
'!') deco+="^bg(${color['red500']})^fg(${color['white']})"
;;
*) deco+="^bg()^fg(${color['grey600']})"
;;
esac
echo -n $deco
}
output_by_tagmark_post() {
$i=$1
local tagmark=${i:0:1}
local deco=""
case $tagmark in
'#')
deco+="^bg(${color['black']})^fg(${color['blue500']})"
deco+="$right_hard_arrow"
;;
*) ;; # do nothing
esac
echo -n $deco
}
output_by_tagnumber() {
i=$1
local index=${i:1}-1
local key=${tag_shows[$index]}
# assuming using dzen2_svn
# clickable tags if using SVN dzen
echo -n "^ca(1,\"${herbstclient_command[@]:-herbstclient}\" "
echo -n "focus_monitor \"$monitor\" && "
echo -n "\"${herbstclient_command[@]:-herbstclient}\" "
echo -n "use \"${i:1}\") ${key} ^ca() "
}
output_leftside_top() {
local left=" ^r(5x0) $separator ^r(5x0) "
left+="$segment_windowtitle"
echo -n $left
echo
}
#!/usr/bin/env bash
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# libraries
DIR=$(dirname "$0")
. ${DIR}/gmc.sh
. ${DIR}/helper.sh
. ${DIR}/output.sh
. ${DIR}/generate.sh
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# initialize
panel_height=24
get_monitor
# do `man herbsluftclient`, and type \pad to search what it means
hc pad $monitor $panel_height 0 $panel_height 0
get_dzen2_parameters $monitor $panel_height
init_segments
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# pipe
# remove all dzen2 instance
pkill dzen2
# By redirecting stderr to /dev/null,
# you effectively suppress these messages.
# 2> /dev/null
hc --idle 2> /dev/null | content 2> /dev/null | dzen2 $dzen2_parameters &
# optional transparency
sleep 2 && exec `(transset .8 -n dzentop >/dev/null 2>&1 &)` &
#!/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
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# 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_dzen2_parameters $monitor $panel_height
echo $dzen2_parameters
#!/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
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# process handler
function test_dzen2() {
monitor=$1
shift
parameters=[email protected]
command_out="dzen2 $parameters -p"
{
# initialize statusbar
set_tag_value $monitor
set_windowtitle 'test'
get_statusbar_text $monitor
echo $buffer
} | $command_out
}
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# 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_dzen2_parameters $monitor $panel_height
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# test
# run process
test_dzen2 $monitor $dzen2_parameters
-- This is a modularized config for herbstluftwm tags in dzen2 statusbar
import System.Environment
import System.Process
import Data.List
import MyHelper
-- initialize
panelHeight = 24
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- main
main = do
-- initialize
args <- getArgs
let monitor = getMonitor args
-- do `man herbsluftclient`, and type \pad to search what it means
system $ "herbstclient pad " ++ show(monitor) ++ " "
++ show(panelHeight) ++ " 0 " ++ show(panelHeight) ++ " 0"
geometry <- getGeometry monitor
let dzen2Parameters = getDzen2Parameters panelHeight geometry
print $ intercalate " " $ dzen2Parameters
-- This is a modularized config for herbstluftwm tags in dzen2 statusbar
import System.Environment
import System.Process
import MyHelper
import System.IO
import GHC.IO.Handle
import MyOutput
-- initialize
panelHeight = 24
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- process handler
testDzen2 :: Int -> [String] -> IO ()
testDzen2 monitor parameters = do
let command_out = "dzen2"
(Just pipe_in, _, _, ph) <-
createProcess (proc command_out (parameters ++ ["-p"]) )
{ std_in = CreatePipe }
-- initialize statusbar before loop
setTagValue monitor
setWindowtitle "test"
text <- getStatusbarText monitor
hPutStrLn pipe_in text
hFlush pipe_in
hClose pipe_in
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- main
main = do
-- initialize
args <- getArgs
let monitor = getMonitor args
-- do `man herbsluftclient`, and type \pad to search what it means
system $ "herbstclient pad " ++ show(monitor) ++ " "
++ show(panelHeight) ++ " 0 " ++ show(panelHeight) ++ " 0"
geometry <- getGeometry monitor
let dzen2Parameters = getDzen2Parameters panelHeight geometry
-- test
-- run process
testDzen2 monitor dzen2Parameters
-- end of IO
return ()
#!/usr/bin/lua
-- This is a modularized config for herbstluftwm tags in dzen2 statusbar
local dirname = debug.getinfo(1).source:match("@?(.*/)")
package.path = package.path .. ';' .. dirname .. '?.lua;'
local helper = require('.helper')
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- initialize
panel_height = 24
monitor = helper.get_monitor(arg)
-- do `man herbsluftclient`, and type \pad to search what it means
os.execute('herbstclient pad ' .. monitor .. ' '
.. panel_height .. ' 0 ' .. panel_height .. ' 0')
dzen2_parameters = helper.get_dzen2_parameters(monitor, panel_height)
print(dzen2_parameters)
#!/usr/bin/lua
-- This is a modularized config for herbstluftwm tags in dzen2 statusbar
local dirname = debug.getinfo(1).source:match("@?(.*/)")
package.path = package.path .. ';' .. dirname .. '?.lua;'
local helper = require('.helper')
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- process handler
function test_dzen2(monitor, parameters)
local output = require('.output')
local command_out = 'dzen2 ' .. parameters .. ' -p'
local pipe_out = assert(io.popen(command_out, 'w'))
-- initialize statusbar before loop
output.set_tag_value(monitor)
output.set_windowtitle('test')
local text = output.get_statusbar_text(monitor)
pipe_out:write(text .. "\n")
pipe_out:flush()
pipe_out:close()