Commit 4e93066e authored by epsi sayidina's avatar epsi sayidina

herbstluftwm tags test

parent 46f87006
......@@ -5,10 +5,7 @@
# libraries
DIR=$(dirname "$0")
. ${DIR}/gmc.sh
. ${DIR}/helper.sh
. ${DIR}/output.sh
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# initialize
......
......@@ -36,15 +36,14 @@ function test_lemon() {
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
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# test
# do `man herbsluftclient`, and type \pad to search what it means
herbstclient pad $monitor $panel_height 0 $panel_height 0
# run process
test_lemon $monitor $lemon_parameters
-- This is a modularized config for herbstluftwm tags in lemonbar
import System.Environment
import System.Process
import Data.List
import MyHelper
......@@ -22,4 +21,4 @@ main = do
geometry <- getGeometry monitor
let lemonParameters = getLemonParameters panelHeight geometry
print $ intercalate " " $ lemonParameters
putStrLn $ intercalate " " $ lemonParameters
......@@ -44,14 +44,14 @@ main = do
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 lemonParameters = getLemonParameters panelHeight geometry
-- test
-- do `man herbsluftclient`, and type \pad to search what it means
system $ "herbstclient pad " ++ show(monitor) ++ " "
++ show(panelHeight) ++ " 0 " ++ show(panelHeight) ++ " 0"
-- run process
testLemon monitor lemonParameters
......
module MyHelper
( getMonitor
, getGeometry
, XYWH (XYWH)
, getTopPanelGeometry
, getBottomPanelGeometry
, getLemonParameters
) where
......@@ -55,9 +58,9 @@ getTopPanelGeometry
getBottomPanelGeometry :: Int -> [Int] -> XYWH
getBottomPanelGeometry
height geometry = XYWH
(show (geometry !! 0))
(show ((geometry !! 0) + 0))
(show ((geometry !! 3) - height))
(show (geometry !! 2))
(show ((geometry !! 2) - 0))
(show height)
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
......@@ -79,7 +82,7 @@ getLemonParameters
-- geometry: -g widthxheight++y
geom_res = width ++ "x" ++ height
++ "+" ++ xpos ++ "+" ++ xpos
++ "+" ++ xpos ++ "+" ++ ypos
-- color, with transparency
bgcolor = "#aa000000"
......
......@@ -29,10 +29,10 @@ tagShows = ["一 ichi", "二 ni", "三 san", "四 shi",
-- simulate global variable using unsafe
segmentWindowtitle :: IORef String
segmentWindowtitle = unsafePerformIO $ newIORef ""
segmentWindowtitle = unsafePerformIO $ newIORef "" -- empty string
tagsStatus :: IORef [String]
tagsStatus = unsafePerformIO $ newIORef []
tagsStatus = unsafePerformIO $ newIORef [] -- empty string list
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- decoration
......
......@@ -9,8 +9,8 @@ local helper = require('.helper')
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- initialize
panel_height = 24
monitor = helper.get_monitor(arg)
local panel_height = 24
local monitor = helper.get_monitor(arg)
lemon_parameters = helper.get_lemon_parameters(monitor, panel_height)
local lemon_parameters = helper.get_lemon_parameters(monitor, panel_height)
print(lemon_parameters)
......@@ -29,16 +29,17 @@ end
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- initialize
panel_height = 24
monitor = helper.get_monitor(arg)
local panel_height = 24
local monitor = helper.get_monitor(arg)
local lemon_parameters = helper.get_lemon_parameters(
monitor, panel_height)
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- test
-- do `man herbsluftclient`, and type \pad to search what it means
os.execute('herbstclient pad ' .. monitor .. ' '
.. panel_height .. ' 0 ' .. panel_height .. ' 0')
lemon_parameters = helper.get_lemon_parameters(monitor, panel_height)
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- test
-- run process
test_lemon(monitor, lemon_parameters)
......@@ -15,7 +15,7 @@ function _M.split(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=0 -- zero based
local t={} ; i=1 -- non zero based
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
......
......@@ -27,18 +27,20 @@ function _M.get_geometry(monitor)
local raw = common.trim1(result)
local geometry = common.split(raw, ' ')
return geometry
end
function _M.get_top_panel_geometry(height, geometry)
-- geometry has the format X Y W H
return geometry[0], geometry[1], geometry[2], height
return tonumber(geometry[1]), tonumber(geometry[2]),
tonumber(geometry[3]), height
end
function _M.get_bottom_panel_geometry(height, geometry)
-- geometry has the format X Y W H
return geometry[0], (geometry[3]-height), geometry[2], height
return tonumber(geometry[1]), tonumber(geometry[4])-height,
tonumber(geometry[3]), height
end
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
......@@ -51,8 +53,8 @@ function _M.get_lemon_parameters(monitor, panel_height)
panel_height, geometry)
-- geometry: -g widthxheight+x+y
local geom_res = width .. 'x' .. height
.. '+' .. xpos .. '+' .. xpos
local geom_res = tostring(width) .. 'x' .. tostring(height)
.. '+' .. tostring(xpos) .. '+' .. tostring(ypos)
-- color, with transparency
local bgcolor = "'#aa000000'"
......
......@@ -15,8 +15,8 @@ _M.tag_shows = {'一 ichi', '二 ni', '三 san', '四 shi',
'五 go', '六 roku', '七 shichi', '八 hachi', '九 kyū', '十 jū'}
-- initialize variable segment
_M.segment_windowtitle = ''
_M.tags_status = {}
_M.segment_windowtitle = '' -- empty string
_M.tags_status = {} -- empty table
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- decoration
......@@ -41,7 +41,7 @@ function _M.get_statusbar_text(monitor)
-- draw tags, zero based
text = text .. '%{l}'
for index = 0, #(_M.tags_status)-1 do
for index = 1, #(_M.tags_status) do
text = text .. _M.output_by_tag(monitor, _M.tags_status[index])
end
......@@ -143,7 +143,6 @@ function _M.set_windowtitle(windowtitle)
' %{B-}%{F' .. gmc.color['grey700'] .. '} ' .. windowtitle
end
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- return
......
......@@ -10,14 +10,14 @@ local pipehandler = require('.pipehandler')
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- initialize
panel_height = 24
monitor = helper.get_monitor(arg)
local panel_height = 24
local 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')
lemon_parameters = helper.get_lemon_parameters(monitor, panel_height)
local lemon_parameters = helper.get_lemon_parameters(monitor, panel_height)
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- main
......
......@@ -39,15 +39,14 @@ sub test_lemon {
my $panel_height = 24;
my $monitor = helper::get_monitor(@ARGV);
# do `man herbsluftclient`, and type \pad to search what it means
system("herbstclient pad $monitor $panel_height 0 $panel_height 0");
my $lemon_parameters = helper::get_lemon_parameters(
$monitor, $panel_height);
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# test
# do `man herbsluftclient`, and type \pad to search what it means
system("herbstclient pad $monitor $panel_height 0 $panel_height 0");
# run process
test_lemon($monitor, $lemon_parameters);
......@@ -19,8 +19,8 @@ use constant TAG_SHOWS => ['一 ichi', '二 ni', '三 san', '四 shi',
'五 go', '六 roku', '七 shichi', '八 hachi', '九 kyū', '十 jū'];
# initialize variable segment
my $segment_windowtitle = '';
my @tags_status = [];
my $segment_windowtitle = ''; # empty string
my @tags_status = []; # empty array
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# decoration
......
......@@ -57,7 +57,7 @@ sub walk_content {
my $wh_out = shift;
# start a pipe
my $command_in = 'herbstclient --idle';
my $command_in = 'herbstclient --idle';
my ($rh_in, $wh_in);
my $pid_in = open2 ($rh_in, $wh_in, $command_in)
......
......@@ -30,15 +30,13 @@ function test_lemon($monitor, $parameters)
$panel_height = 24;
$monitor = get_monitor($argv);
// do `man herbsluftclient`, and type \pad to search what it means
system("herbstclient pad $monitor $panel_height 0 $panel_height 0");
$lemon_parameters = get_lemon_parameters($monitor, $panel_height);
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# test
// do `man herbsluftclient`, and type \pad to search what it means
system("herbstclient pad $monitor $panel_height 0 $panel_height 0");
// run process
test_lemon($monitor, $lemon_parameters);
......@@ -12,8 +12,8 @@ const TAG_SHOWS = ['一 ichi', '二 ni', '三 san', '四 shi',
'五 go', '六 roku', '七 shichi', '八 hachi', '九 kyū', '十 jū'];
// initialize variable segment
$segment_windowtitle = '';
$tags_status = [];
$segment_windowtitle = ''; # empty string
$tags_status = []; # empty array
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# decoration
......
#!/usr/bin/env python3
# This is a modularized config for herbstluftwm tags in lemonbar
import os
import sys
import helper
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
......
......@@ -37,15 +37,14 @@ def test_lemon(monitor, parameters):
panel_height = 24
monitor = helper.get_monitor(sys.argv)
# do `man herbsluftclient`, and type \pad to search what it means
os.system('herbstclient pad ' + str(monitor) + ' '
+ str(panel_height) + ' 0 ' + str(panel_height) + ' 0')
lemon_parameters = helper.get_lemon_parameters(monitor, panel_height)
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# test
# do `man herbsluftclient`, and type \pad to search what it means
os.system('herbstclient pad ' + str(monitor) + ' '
+ str(panel_height) + ' 0 ' + str(panel_height) + ' 0')
# run process
test_lemon(monitor, lemon_parameters);
test_lemon(monitor, lemon_parameters)
......@@ -20,17 +20,19 @@ def get_geometry(monitor):
print('Invalid monitor ' + str(monitor))
exit(1)
geometry = raw.split(' ')
geometry = raw.rstrip().split(' ')
return geometry
def get_top_panel_geometry(height, geometry):
# geometry has the format X Y W H
return (geometry[0], geometry[1], geometry[2], height)
return (int(geometry[0]), int(geometry[1]),
int(geometry[2]), height)
def get_bottom_panel_geometry(height, geometry):
# geometry has the format X Y W H
return (geometry[0], geometry[3]-height, geometry[2], height)
return (int(geometry[0]), int(geometry[3])-height,
int(geometry[2]), height )
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# lemon Parameters
......@@ -42,7 +44,7 @@ def get_lemon_parameters(monitor, panel_height):
panel_height, geometry)
# geometry: -g widthxheight+x+y
geom_res = str(width)+'x'+str(height)+'+'+str(xpos)+'+'+str(xpos)
geom_res = str(width)+'x'+str(height)+'+'+str(xpos)+'+'+str(ypos)
# color, with transparency
bgcolor = "'#aa000000'"
......
......@@ -13,8 +13,8 @@ TAG_SHOWS = ['一 ichi', '二 ni', '三 san', '四 shi',
'五 go', '六 roku', '七 shichi', '八 hachi', '九 kyū', '十 jū']
# initialize variable segment
segment_windowtitle = ''
tags_status = []
segment_windowtitle = '' # empty string
tags_status = [] # empty list
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# decoration
......
......@@ -25,17 +25,15 @@ end
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# initialize
panel_height = 24
monitor = get_monitor(ARGV)
# do `man herbsluftclient`, and type \pad to search what it means
system("herbstclient pad #{monitor} #{panel_height} 0 #{panel_height} 0")
lemon_parameters = get_lemon_parameters(monitor, panel_height)
local panel_height = 24
local monitor = get_monitor(ARGV)
local lemon_parameters = get_lemon_parameters(monitor, panel_height)
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# test
# do `man herbsluftclient`, and type \pad to search what it means
system("herbstclient pad #{monitor} #{panel_height} 0 #{panel_height} 0")
# run process
test_lemon(monitor, lemon_parameters)
......@@ -25,12 +25,13 @@ end
def get_top_panel_geometry(height, geometry)
# geometry has the format X Y W H
return geometry[0], geometry[1], geometry[2], height
return geometry[0].to_i, geometry[1].to_i, geometry[2].to_i, height
end
def get_bottom_panel_geometry(height, geometry)
# geometry has the format X Y W H
return geometry[0], (geometry[3]-height), geometry[2], height
return geometry[0].to_i, (geometry[3].to_i - height),
geometry[2].to_i, height
end
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
......@@ -43,7 +44,7 @@ def get_lemon_parameters(monitor, panel_height)
panel_height, geometry)
# geometry: -g widthxheight+x+y
geom_res = "#{width}x#{height}+#{xpos}+#{ypos}";
geom_res = "#{width}x#{height}+#{xpos}+#{ypos}"
# color, with transparency
bgcolor = "'#aa000000'"
......
......@@ -8,8 +8,8 @@ include GMC
# #1 :2 :3 :4 .5 .6 .7 .8 .9
# initialize variable segment
segment_windowtitle = ''
tags_status = []
segment_windowtitle = '' # empty string
tags_status = [] # empty array
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# decoration
......
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