You are not logged in.
Hi, I'm interested if I can use 'characters' instead of 'images' as layout indicators. I was searching at the Internet about this but I can not find answer.
Offline
While I'm not sure exactly how you'd use text, I'd bet that it's possible. The thing is, it might require writing more code into rc.lua than is necessary for referencing the images. You can always just create text images in GIMP and use those instead of the layout icons.
Offline
Thx for reply ANOKNUSA!
I'm using 'handmade' icons made in GIMP. They are ok and nice.. but I was only interested about using text instead of images
Offline
Well, awful.widget.layoutbox is based on an imagebox widget, so no, there's not a straightforward way of doing this.
You can make your own layoutbox widget, though. Something like:
function new_text_layoutbox(screen, args)
local screen = screen or 1
local args = args or {}
args.type = "textbox"
local w = capi.widget(args)
update(w, screen)
local function update_on_tag_selection(tag)
w.text = layout.getname(layout.get(tag.screen))
end
tag.attached_add_signal(screen, "property::selected", update_on_tag_selection)
tag.attached_add_signal(screen, "property::layout", update_on_tag_selection)
return w
end
Untested, and hastily adapted from awful.widget.layoutbox. Not guaranteed to work, but it gives you an idea of what you could do.
Offline
Yep, this thread is old but since I wanted to use such a widget in my wibar and could not find any other ressource I wanted to share my *working* config.
The widget from above shows a string defined in your theme.lua file (syntax: theme.layout_txt_$LAYOUT)
$ cat $XDG_CONFIG_HOME/rc.lua
-- Writes a string representation of the current layout in a textbox widget
function updatelayoutbox(l, s)
local screen = s or 1
l.text = beautiful["layout_txt_" .. awful.layout.getname(awful.layout.get(screen))]
end
[...]
for s = 1, screen.count() do
-- Create a promptbox for each screen
mypromptbox[s] =
awful.widget.prompt({layout = awful.widget.layout.leftright})
-- Create a textbox widget which will contains a short string representing the
-- layout we're using. We need one layoutbox per screen.
txtlayoutbox[s] = widget({ type = "textbox" })
txtlayoutbox[s].text = beautiful["layout_txt_" .. awful.layout.getname(awful.layout.get(s))]
awful.tag.attached_add_signal(s, "property::selected", function ()
updatelayoutbox(txtlayoutbox[s], s)
end)
awful.tag.attached_add_signal(s, "property::layout", function ()
updatelayoutbox(txtlayoutbox[s], s)
end)
txtlayoutbox[s]:buttons(awful.util.table.join(
awful.button({}, 1, function() awful.layout.inc(layouts, 1) end),
awful.button({}, 3, function() awful.layout.inc(layouts, -1) end),
awful.button({}, 4, function() awful.layout.inc(layouts, 1) end),
awful.button({}, 5, function() awful.layout.inc(layouts, -1) end)))
[...]
end
for s = 1, screen.count() do
-- Add widgets to the wibox - order matters
mywibox[s].widgets = {
{
mytaglist[s],
txtlayoutbox[s],
[...]
},
[...]
mywibox[s].screen = s
end
$ cat $XDG_CONFIG_HOME/themes/default/theme.lua
theme.layout_txt_tile = "[t]"
theme.layout_txt_tileleft = "[l]"
theme.layout_txt_tilebottom = "[b]"
theme.layout_txt_tiletop = "[tt]"
theme.layout_txt_fairv = "[fv]"
theme.layout_txt_fairh = "[fh]"
theme.layout_txt_spiral = "[s]"
theme.layout_txt_dwindle = "[d]"
theme.layout_txt_max = "[m]"
theme.layout_txt_fullscreen = "[F]"
theme.layout_txt_magnifier = "[M]"
theme.layout_txt_floating = "[*]"
Last edited by pschmitt (2012-11-19 21:17:37)
Offline
Thank you pschmitt, it is working.
Here is my diff for the record:
--- rc.lua.bak 2013-03-30 10:01:22.800318739 +0100
+++ rc.lua 2013-03-30 11:37:23.892369406 +0100
@@ -45,7 +45,8 @@
-- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers
-beautiful.init("/usr/share/awesome/themes/default/theme.lua")
+theme_path = awful.util.getdir("config") .. "/themes/default/theme.lua"
+beautiful.init(theme_path)
-- This is used later as the default terminal and editor to run.
terminal = "x-terminal-emulator"
@@ -126,9 +127,16 @@
-- Create a systray
mysystray = widget({ type = "systray" })
+-- Writes a string representation of the current layout in a textbox widget
+function updatelayoutbox(l, s)
+ local screen = s or 1
+ l.text = beautiful["layout_txt_" .. awful.layout.getname(awful.layout.get(screen))]
+end
+
-- Create a wibox for each screen and add it
mywibox = {}
mypromptbox = {}
+txtlayoutbox = {}
mylayoutbox = {}
mytaglist = {}
mytaglist.buttons = awful.util.table.join(
@@ -174,6 +182,16 @@
for s = 1, screen.count() do
-- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
+ -- Create a textbox widget which will contain a short string representing the
+ -- layout we're using. We need one layoutbox per screen.
+ txtlayoutbox[s] = widget({ type = "textbox" })
+ txtlayoutbox[s].text = beautiful["layout_txt_" .. awful.layout.getname(awful.layout.get(s))]
+ awful.tag.attached_add_signal(s, "property::selected", function ()
+ updatelayoutbox(txtlayoutbox[s], s)
+ end)
+ awful.tag.attached_add_signal(s, "property::layout", function ()
+ updatelayoutbox(txtlayoutbox[s], s)
+ end)
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
mylayoutbox[s] = awful.widget.layoutbox(s)
@@ -182,6 +200,11 @@
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
+ txtlayoutbox[s]:buttons(awful.util.table.join(
+ awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
+ awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
+ awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
+ awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
-- Create a taglist widget
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
@@ -201,6 +224,7 @@
layout = awful.widget.layout.horizontal.leftright
},
mylayoutbox[s],
+ txtlayoutbox[s], separator,
mytextclock,
separator, netwidget,
s == 1 and mysystray or nil,
Last edited by dash (2013-03-30 10:38:25)
Offline