Commit 0ce49173 authored by epsi sayidina's avatar epsi sayidina

herbstluftwm combined event

parent 8f98ff5d
......@@ -26,7 +26,8 @@ function handle_command_event() {
set_tag_value $monitor
;;
focus_changed|window_title_changed)
set_windowtitle "${column[2]}"
[[ ${#column[@]} > 2 ]] && title=${column[2]} || title=''
set_windowtitle "$title"
;;
esac
}
......
......@@ -26,7 +26,8 @@ function handle_command_event() {
set_tag_value $monitor
;;
focus_changed|window_title_changed)
set_windowtitle "${column[2]}"
[[ ${#column[@]} > 2 ]] && title=${column[2]} || title=''
set_windowtitle "$title"
;;
interval)
set_datetime
......
......@@ -26,7 +26,8 @@ function handle_command_event() {
set_tag_value $monitor
;;
focus_changed|window_title_changed)
set_windowtitle "${column[2]}"
[[ ${#column[@]} > 2 ]] && title=${column[2]} || title=''
set_windowtitle "$title"
;;
interval)
set_datetime
......
......@@ -30,12 +30,17 @@ wSleep mySecond = threadDelay (1000000 * mySecond)
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- pipe
getColumnTitle :: [String] -> String
getColumnTitle column
| length(column) > 2 = column !! 2
| otherwise = ""
handleCommandEvent :: Int -> String -> IO ()
handleCommandEvent monitor event
| origin == "reload" = do system("pkill dzen2"); return ()
| origin == "quit_panel" = do exitSuccess; return ()
| elem origin tagCmds = do setTagValue monitor
| elem origin titleCmds = do setWindowtitle (column !! 2)
| elem origin titleCmds = do setWindowtitle $ getColumnTitle column
where
tagCmds = ["tag_changed", "tag_flags", "tag_added", "tag_removed"]
titleCmds = ["window_title_changed", "focus_changed"]
......
......@@ -30,12 +30,17 @@ wSleep mySecond = threadDelay (1000000 * mySecond)
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- pipe
getColumnTitle :: [String] -> String
getColumnTitle column
| length(column) > 2 = column !! 2
| otherwise = ""
handleCommandEvent :: Int -> String -> IO ()
handleCommandEvent monitor event
| origin == "reload" = do system("pkill dzen2"); return ()
| origin == "quit_panel" = do exitSuccess; return ()
| elem origin tagCmds = do setTagValue monitor
| elem origin titleCmds = do setWindowtitle (column !! 2)
| elem origin titleCmds = do setWindowtitle $ getColumnTitle column
| origin == "interval" = do setDatetime
where
tagCmds = ["tag_changed", "tag_flags", "tag_added", "tag_removed"]
......
......@@ -30,12 +30,17 @@ wSleep mySecond = threadDelay (1000000 * mySecond)
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- pipe
getColumnTitle :: [String] -> String
getColumnTitle column
| length(column) > 2 = column !! 2
| otherwise = ""
handleCommandEvent :: Int -> String -> IO ()
handleCommandEvent monitor event
| origin == "reload" = do system("pkill dzen2"); return ()
| origin == "quit_panel" = do exitSuccess; return ()
| elem origin tagCmds = do setTagValue monitor
| elem origin titleCmds = do setWindowtitle (column !! 2)
| elem origin titleCmds = do setWindowtitle $ getColumnTitle column
| origin == "interval" = do setDatetime
where
tagCmds = ["tag_changed", "tag_flags", "tag_added", "tag_removed"]
......
......@@ -25,7 +25,8 @@ function _M.handle_command_event(monitor, event)
elseif common.has_value(tag_cmds, origin) then
output.set_tag_value(monitor)
elseif common.has_value(title_cmds, origin) then
output.set_windowtitle(column[3])
local title = (#column > 2) and (column[3]) or ''
output.set_windowtitle(title)
end
end
......
......@@ -33,7 +33,8 @@ function _M.handle_command_event(monitor, event)
elseif common.has_value(tag_cmds, origin) then
output.set_tag_value(monitor)
elseif common.has_value(title_cmds, origin) then
output.set_windowtitle(column[3])
local title = (#column > 2) and (column[3]) or ''
output.set_windowtitle(title)
elseif origin == 'interval' then
output.set_datetime()
end
......
......@@ -33,7 +33,8 @@ function _M.handle_command_event(monitor, event)
elseif common.has_value(tag_cmds, origin) then
output.set_tag_value(monitor)
elseif common.has_value(title_cmds, origin) then
output.set_windowtitle(column[3])
local title = (#column > 2) and (column[3]) or ''
output.set_windowtitle(title)
elseif origin == 'interval' then
output.set_datetime()
end
......
......@@ -35,7 +35,8 @@ sub handle_command_event {
} elsif ( ($origin eq 'window_title_changed')
or ($origin eq 'focus_changed')
) {
output::set_windowtitle($column[2]);
my $title = ($#column > 2) ? $column[2] : '';
output::set_windowtitle($title);
}
}
......
......@@ -37,7 +37,8 @@ sub handle_command_event {
} elsif ( ($origin eq 'window_title_changed')
or ($origin eq 'focus_changed')
) {
output::set_windowtitle($column[2]);
my $title = ($#column > 2) ? $column[2] : '';
output::set_windowtitle($title);
} elsif ($origin eq 'interval') {
output::set_datetime();
}
......
......@@ -37,7 +37,8 @@ sub handle_command_event {
} elsif ( ($origin eq 'window_title_changed')
or ($origin eq 'focus_changed')
) {
output::set_windowtitle($column[2]);
my $title = ($#column > 2) ? $column[2] : '';
output::set_windowtitle($title);
} elsif ($origin eq 'interval') {
output::set_datetime();
}
......
......@@ -25,8 +25,8 @@ function handle_command_event($monitor, $event)
break;
case 'window_title_changed':
case 'focus_changed':
set_windowtitle($column[2]);
break;
$title = count($column) > 2 ? $column[2] : '';
set_windowtitle($title);
}
}
......
......@@ -25,7 +25,8 @@ function handle_command_event($monitor, $event)
break;
case 'window_title_changed':
case 'focus_changed':
set_windowtitle($column[2]);
$title = count($column) > 2 ? $column[2] : '';
set_windowtitle($title);
break;
case 'interval':
set_datetime();
......
......@@ -25,7 +25,8 @@ function handle_command_event($monitor, $event)
break;
case 'window_title_changed':
case 'focus_changed':
set_windowtitle($column[2]);
$title = count($column) > 2 ? $column[2] : '';
set_windowtitle($title);
break;
case 'interval':
set_datetime();
......
......@@ -28,7 +28,12 @@ def run_dzen2(monitor, parameters):
content_init(monitor, pipe_dzen2_out)
pipe_dzen2_out.stdin.close()
def detach_dzen2_debug(monitor, parameters):
run_lemon(monitor, parameters)
def detach_dzen2(monitor, parameters):
# in case of debugging purpose,
# uncomment all the fork related lines.
pid_dzen2 = os.fork()
if pid_dzen2 == 0:
......
......@@ -22,7 +22,8 @@ def handle_command_event(monitor, event):
elif origin in tag_cmds:
output.set_tag_value(monitor)
elif origin in title_cmds:
output.set_windowtitle(column[2])
title = column[2] if (len(column) > 2) else ''
output.set_windowtitle(title)
def content_init(monitor, pipe_dzen2_out):
# initialize statusbar before loop
......@@ -70,7 +71,12 @@ def run_dzen2(monitor, parameters):
pipe_dzen2_out.stdin.close()
def detach_dzen2_debug(monitor, parameters):
run_lemon(monitor, parameters)
def detach_dzen2(monitor, parameters):
# in case of debugging purpose,
# uncomment all the fork related lines.
pid_dzen2 = os.fork()
if pid_dzen2 == 0:
......
......@@ -22,7 +22,8 @@ def handle_command_event(monitor, event):
elif origin in tag_cmds:
output.set_tag_value(monitor)
elif origin in title_cmds:
output.set_windowtitle(column[2])
title = column[2] if (len(column) > 2) else ''
output.set_windowtitle(title)
elif origin == 'interval':
output.set_datetime()
......@@ -113,6 +114,9 @@ def run_dzen2(monitor, parameters):
pipe_dzen2_out.stdin.close()
def detach_dzen2_debug(monitor, parameters):
run_lemon(monitor, parameters)
def detach_dzen2(monitor, parameters):
# in case of debugging purpose,
# uncomment all the fork related lines.
......
......@@ -22,7 +22,8 @@ def handle_command_event(monitor, event):
elif origin in tag_cmds:
output.set_tag_value(monitor)
elif origin in title_cmds:
output.set_windowtitle(column[2])
title = column[2] if (len(column) > 2) else ''
output.set_windowtitle(title)
elif origin == 'interval':
output.set_datetime()
......@@ -113,6 +114,9 @@ def run_dzen2(monitor, parameters):
pipe_dzen2_out.stdin.close()
def detach_dzen2_debug(monitor, parameters):
run_lemon(monitor, parameters)
def detach_dzen2(monitor, parameters):
# in case of debugging purpose,
# uncomment all the fork related lines.
......
......@@ -19,7 +19,8 @@ def handle_command_event(monitor, event)
when *tag_cmds # splat operator
set_tag_value(monitor)
when *title_cmds # splat operator
set_windowtitle(column[2])
title = column.length > 2 ? column[2] : ''
set_windowtitle(title)
end
end
......
......@@ -19,7 +19,8 @@ def handle_command_event(monitor, event)
when *tag_cmds # splat operator
set_tag_value(monitor)
when *title_cmds # splat operator
set_windowtitle(column[2])
title = column.length > 2 ? column[2] : ''
set_windowtitle(title)
when 'interval'
set_datetime()
end
......
......@@ -19,7 +19,8 @@ def handle_command_event(monitor, event)
when *tag_cmds # splat operator
set_tag_value(monitor)
when *title_cmds # splat operator
set_windowtitle(column[2])
title = column.length > 2 ? column[2] : ''
set_windowtitle(title)
when 'interval'
set_datetime()
end
......
......@@ -24,10 +24,7 @@ function content_event_interval() {
pid_interval=$!
} | while read event; do
echo "$event"
# uncomment to examine more complete behaviour
# echo -e "tab:\t[${event}]"
echo -e "event:\t[${event}]"
done
kill pid_idle
......
......@@ -26,7 +26,8 @@ function handle_command_event() {
set_tag_value $monitor
;;
focus_changed|window_title_changed)
set_windowtitle "${column[2]}"
[[ ${#column[@]} > 2 ]] && title=${column[2]} || title=''
set_windowtitle "$title"
;;
esac
}
......
......@@ -26,7 +26,8 @@ function handle_command_event() {
set_tag_value $monitor
;;
focus_changed|window_title_changed)
set_windowtitle "${column[2]}"
[[ ${#column[@]} > 2 ]] && title=${column[2]} || title=''
set_windowtitle "$title"
;;
esac
}
......
......@@ -26,7 +26,8 @@ function handle_command_event() {
set_tag_value $monitor
;;
focus_changed|window_title_changed)
set_windowtitle "${column[2]}"
[[ ${#column[@]} > 2 ]] && title=${column[2]} || title=''
set_windowtitle "$title"
;;
interval)
set_datetime
......
......@@ -25,8 +25,9 @@ function handle_command_event() {
# echo "resetting tags" >&2
set_tag_value $monitor
;;
focus_changed|window_title_changed)
set_windowtitle "${column[2]}"
focus_changed|window_title_changed)
[[ ${#column[@]} > 2 ]] && title=${column[2]} || title=''
set_windowtitle "$title"
;;
interval)
set_datetime
......
......@@ -64,10 +64,7 @@ main = do
forever $ do
-- wait for next event
event <- hGetLine pipe_cat_out
putStrLn event
-- uncomment to examine more complete behaviour
-- putStrLn $ "tab:\t[" ++ event ++ "]"
putStrLn $ "event:\t[" ++ event ++ "]"
hClose pipe_cat_out
hClose pipe_cat_in
......
......@@ -22,12 +22,17 @@ import MyOutput
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- pipe
getColumnTitle :: [String] -> String
getColumnTitle column
| length(column) > 2 = column !! 2
| otherwise = ""
handleCommandEvent :: Int -> String -> IO ()
handleCommandEvent monitor event
| origin == "reload" = do system("pkill lemonbar"); return ()
| origin == "quit_panel" = do exitSuccess; return ()
| elem origin tagCmds = do setTagValue monitor
| elem origin titleCmds = do setWindowtitle (column !! 2)
| elem origin titleCmds = do setWindowtitle $ getColumnTitle column
where
tagCmds = ["tag_changed", "tag_flags", "tag_added", "tag_removed"]
titleCmds = ["window_title_changed", "focus_changed"]
......
......@@ -22,12 +22,17 @@ import MyOutput
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- pipe
getColumnTitle :: [String] -> String
getColumnTitle column
| length(column) > 2 = column !! 2
| otherwise = ""
handleCommandEvent :: Int -> String -> IO ()
handleCommandEvent monitor event
| origin == "reload" = do system("pkill lemonbar"); return ()
| origin == "quit_panel" = do exitSuccess; return ()
| elem origin tagCmds = do setTagValue monitor
| elem origin titleCmds = do setWindowtitle (column !! 2)
| elem origin titleCmds = do setWindowtitle $ getColumnTitle column
where
tagCmds = ["tag_changed", "tag_flags", "tag_added", "tag_removed"]
titleCmds = ["window_title_changed", "focus_changed"]
......
......@@ -28,12 +28,17 @@ wSleep mySecond = threadDelay (1000000 * mySecond)
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- pipe
getColumnTitle :: [String] -> String
getColumnTitle column
| length(column) > 2 = column !! 2
| otherwise = ""
handleCommandEvent :: Int -> String -> IO ()
handleCommandEvent monitor event
| origin == "reload" = do system("pkill lemonbar"); return ()
| origin == "quit_panel" = do exitSuccess; return ()
| elem origin tagCmds = do setTagValue monitor
| elem origin titleCmds = do setWindowtitle (column !! 2)
| elem origin titleCmds = do setWindowtitle $ getColumnTitle column
| origin == "interval" = do setDatetime
where
tagCmds = ["tag_changed", "tag_flags", "tag_added", "tag_removed"]
......
......@@ -28,12 +28,17 @@ wSleep mySecond = threadDelay (1000000 * mySecond)
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- pipe
getColumnTitle :: [String] -> String
getColumnTitle column
| length(column) > 2 = column !! 2
| otherwise = ""
handleCommandEvent :: Int -> String -> IO ()
handleCommandEvent monitor event
| origin == "reload" = do system("pkill lemonbar"); return ()
| origin == "quit_panel" = do exitSuccess; return ()
| elem origin tagCmds = do setTagValue monitor
| elem origin titleCmds = do setWindowtitle (column !! 2)
| elem origin titleCmds = do setWindowtitle $ getColumnTitle column
| origin == "interval" = do setDatetime
where
tagCmds = ["tag_changed", "tag_flags", "tag_added", "tag_removed"]
......
......@@ -74,10 +74,7 @@ while true do
event = trim1(posix.read(rd, bufsize))
if event == nil or #event == 0 then break end
print(event)
-- uncomment to examine more complete behaviour
-- print("tab:\t[" .. event .."]")
print("event:\t[" .. event .."]")
end
posix.close(rd)
......
......@@ -12,11 +12,12 @@ local _M = {}
function _M.handle_command_event(monitor, event)
-- find out event origin
column = common.split(event, "\t")
origin = column[1] -- non zero based
local column = common.split(event, "\t")
local origin = column[1] -- non zero based
tag_cmds = {'tag_changed', 'tag_flags', 'tag_added', 'tag_removed'}
title_cmds = {'window_title_changed', 'focus_changed'}
local tag_cmds = {'tag_changed',
'tag_flags', 'tag_added', 'tag_removed'}
local title_cmds = {'window_title_changed', 'focus_changed'}
if origin == 'reload' then
os.execute('pkill lemonbar')
......@@ -25,7 +26,8 @@ function _M.handle_command_event(monitor, event)
elseif common.has_value(tag_cmds, origin) then
output.set_tag_value(monitor)
elseif common.has_value(title_cmds, origin) then
output.set_windowtitle(column[3])
local title = (#column > 2) and (column[3]) or ''
output.set_windowtitle(title)
end
end
......
......@@ -12,11 +12,12 @@ local _M = {}
function _M.handle_command_event(monitor, event)
-- find out event origin
column = common.split(event, "\t")
origin = column[1] -- non zero based
local column = common.split(event, "\t")
local origin = column[1] -- non zero based
tag_cmds = {'tag_changed', 'tag_flags', 'tag_added', 'tag_removed'}
title_cmds = {'window_title_changed', 'focus_changed'}
local tag_cmds = {'tag_changed',
'tag_flags', 'tag_added', 'tag_removed'}
local title_cmds = {'window_title_changed', 'focus_changed'}
if origin == 'reload' then
os.execute('pkill lemonbar')
......@@ -25,7 +26,8 @@ function _M.handle_command_event(monitor, event)
elseif common.has_value(tag_cmds, origin) then
output.set_tag_value(monitor)
elseif common.has_value(title_cmds, origin) then
output.set_windowtitle(column[3])
local title = (#column > 2) and (column[3]) or ''
output.set_windowtitle(title)
end
end
......
......@@ -20,11 +20,12 @@ end
function _M.handle_command_event(monitor, event)
-- find out event origin
column = common.split(event, "\t")
origin = column[1] -- non zero based
local column = common.split(event, "\t")
local origin = column[1] -- non zero based
tag_cmds = {'tag_changed', 'tag_flags', 'tag_added', 'tag_removed'}
title_cmds = {'window_title_changed', 'focus_changed'}
local tag_cmds = {'tag_changed',
'tag_flags', 'tag_added', 'tag_removed'}
local title_cmds = {'window_title_changed', 'focus_changed'}
if origin == 'reload' then
os.execute('pkill lemonbar')
......@@ -33,7 +34,8 @@ function _M.handle_command_event(monitor, event)
elseif common.has_value(tag_cmds, origin) then
output.set_tag_value(monitor)
elseif common.has_value(title_cmds, origin) then
output.set_windowtitle(column[3])
local title = (#column > 2) and (column[3]) or ''
output.set_windowtitle(title)
elseif origin == 'interval' then
output.set_datetime()
end
......
......@@ -20,11 +20,12 @@ end
function _M.handle_command_event(monitor, event)
-- find out event origin
column = common.split(event, "\t")
origin = column[1] -- non zero based
local column = common.split(event, "\t")
local origin = column[1] -- non zero based
tag_cmds = {'tag_changed', 'tag_flags', 'tag_added', 'tag_removed'}
title_cmds = {'window_title_changed', 'focus_changed'}
local tag_cmds = {'tag_changed',
'tag_flags', 'tag_added', 'tag_removed'}
local title_cmds = {'window_title_changed', 'focus_changed'}
if origin == 'reload' then
os.execute('pkill lemonbar')
......@@ -33,7 +34,8 @@ function _M.handle_command_event(monitor, event)
elseif common.has_value(tag_cmds, origin) then
output.set_tag_value(monitor)
elseif common.has_value(title_cmds, origin) then
output.set_windowtitle(column[3])
local title = (#column > 2) and (column[3]) or ''
output.set_windowtitle(title)
elseif origin == 'interval' then
output.set_datetime()
end
......@@ -111,7 +113,7 @@ function _M.content_walk(monitor, pipe_lemon_out)
end
function _M.run_lemon(monitor, parameters)
-- no bidirectional in Lua, using shell pipe instead, or posix
-- no bidirectional in Lua, using shell pipe instead
local command_out = 'lemonbar ' .. parameters .. ' | sh'
local pipe_lemon_out = assert(io.popen(command_out, 'w'))
......
......@@ -64,11 +64,7 @@ content_event_idle($wh_cat);
content_event_interval($wh_cat);
while (chomp($event = <$rh_cat>)) {
print "$event\n";
# uncomment to examine more complete behaviour
#print "tab:\t[$event]\n";
print "event:\t[$event]\n";
flush STDOUT;
}
......
......@@ -37,7 +37,8 @@ sub handle_command_event {
} elsif ( ($origin eq 'window_title_changed')
or ($origin eq 'focus_changed')
) {
output::set_windowtitle($column[2]);
my $title = ($#column > 2) ? $column[2] : '';
output::set_windowtitle($title);
}
}
......
......@@ -37,7 +37,8 @@ sub handle_command_event {
} elsif ( ($origin eq 'window_title_changed')
or ($origin eq 'focus_changed')
) {
output::set_windowtitle($column[2]);
my $title = ($#column > 2) ? $column[2] : '';
output::set_windowtitle($title);
}
}
......
......@@ -39,7 +39,8 @@ sub handle_command_event {
) {
output::set_windowtitle($column[2]);
} elsif ($origin eq 'interval') {
output::set_datetime();
my $title = ($#column > 2) ? $column[2] : '';
output::set_windowtitle($title);
}
}
......
......@@ -37,7 +37,8 @@ sub handle_command_event {
} elsif ( ($origin eq 'window_title_changed')
or ($origin eq 'focus_changed')
) {
output::set_windowtitle($column[2]);
my $title = ($#column > 2) ? $column[2] : '';
output::set_windowtitle($title);
} elsif ($origin eq 'interval') {
output::set_datetime();
}
......
......@@ -45,7 +45,7 @@ function get_statusbar_text($monitor)
$text .= output_by_tag($monitor, $tag_status);
}
# draw window title
# draw date time
$text .= '%{c}';
$text .= output_by_datetime();
......
......@@ -25,8 +25,8 @@ function handle_command_event($monitor, $event)
break;
case 'window_title_changed':
case 'focus_changed':
set_windowtitle($column[2]);
break;
$title = count($column) > 2 ? $column[2] : '';
set_windowtitle($title);
}
}
......
......@@ -25,8 +25,8 @@ function handle_command_event($monitor, $event)
break;
case 'window_title_changed':
case 'focus_changed':
set_windowtitle($column[2]);
break;
$title = count($column) > 2 ? $column[2] : '';
set_windowtitle($title);
}
}
......
......@@ -25,7 +25,8 @@ function handle_command_event($monitor, $event)
break;
case 'window_title_changed':
case 'focus_changed':
set_windowtitle($column[2]);
$title = count($column) > 2 ? $column[2] : '';