[UP] use ion3-plus haha.
[arrow.git] / archlinux_conf / etc / ion3 / old / statusbar_workspace.lua
blobf86cf296b9f4d1bc11f0273681501280a7ee703e
1 -- statusbar_workspace.lua
2 --
3 -- Show current workspace name or number in the statusbar.
4 --
5 -- Put any of these in cfg_statusbar.lua's template-line:
6 -- %workspace_name
7 -- %workspace_frame
8 -- %workspace_pager
9 -- %workspace_name_pager
10 -- %workspace_num_name_pager
12 -- This is an internal statusbar monitor and does NOT require
13 -- a dopath statement (effective after a 2006-02-12 build).
15 -- version 1
16 -- author: Rico Schiekel <fire at paranetic dot de>
18 -- version 2
19 -- added 2006-02-14 by Canaan Hadley-Voth:
20 -- * %workspace_pager shows a list of workspace numbers
21 -- with the current one indicated:
23 -- 1i 2i [3f] 4p 5c
25 -- i=WIonWS, f=WFloatWS, p=WPaneWS, c=WClientWin/other
27 -- * %workspace_frame - name of the active frame.
29 -- * Added statusbar_ to the filename (since it *is*
30 -- an internal statusbar monitor) so that it works without
31 -- a "dopath" call.
33 -- * Removed timer. Only needs to run on hook.
34 -- Much faster this way.
36 -- version 3
37 -- update for ion-3rc-20070506 on 2007-05-09
38 -- by Kevin Granade <kevin dot granade at gmail dot com>
40 -- Updated to use new wx_ api
41 -- Replaced region_activated_hook with region_notify_hook
42 -- Added %workspace_name_pager, which works similarly to %workspace_pager,
43 -- but instead displays the name of each workspace
44 -- Added display for WGroupWS to %workspace_pager, displayed as 'g'
45 --
47 local function update_frame()
48 local fr
49 ioncore.defer( function()
50 local cur=ioncore.current()
51 if obj_is(cur, "WClientWin") and
52 obj_is(cur:parent(), "WMPlex") then
53 cur=cur:parent()
54 end
55 fr=cur:name()
56 mod_statusbar.inform('workspace_frame', fr)
57 mod_statusbar.update()
58 end)
59 end
61 local function update_workspace()
62 local scr=ioncore.find_screen_id(0)
63 local curws = scr:mx_current()
64 local wstype, c
65 local pager=""
66 local name_pager=""
67 local name_pager_plus=""
68 local curindex = scr:get_index(curws)+1
69 n = scr:mx_count(1)
70 for i=1,n do
71 tmpws=scr:mx_nth(i-1)
72 wstype=obj_typename(tmpws)
73 if wstype=="WIonWS" then
74 c="i"
75 elseif wstype=="WFloatWS" then
76 c="f"
77 elseif wstype=="WPaneWS" then
78 c="p"
79 elseif wstype=="WGroupWS" then
80 c="g"
81 else
82 c="c"
83 end
84 if i==curindex then
85 name_pager_plus=name_pager_plus.." ["..tmpws:name().."]"
86 name_pager=name_pager.." ["..tmpws:name().."]"
87 pager=pager.." ["..(i)..c.."] "
88 else
89 name_pager_plus=name_pager_plus.." "..(i)..":"..tmpws:name()
90 name_pager=name_pager.." "..tmpws:name()
91 pager=pager.." "..(i)..c.." "
92 end
93 end
95 local fr,cur
97 -- Older versions without an ioncore.current() should
98 -- skip update_frame.
99 update_frame()
101 ioncore.defer( function()
102 mod_statusbar.inform('workspace_pager', pager)
103 mod_statusbar.inform('workspace_name', curws:name())
104 mod_statusbar.inform('workspace_name_pager', name_pager)
105 mod_statusbar.inform('workspace_num_name_pager', name_pager_plus)
106 mod_statusbar.update()
107 end)
110 ioncore.get_hook("region_notify_hook"):add(update_workspace)