7

I am looking to replace the tag list in awesome WM with a simple text box that only displays the name of the current tag. I have tried to create a textbox that contains the following code:

mytagbox = widget({ type = "textbox" })
mytagbox.text = awful.tag.selected(s).getproperty("name")

But this does not work and reverts awesome to its default config. What is the correct code I need to put in to make this possible? I'm also using Shifty. Thanks

semiserious
  • 610
  • 1
  • 8
  • 12

2 Answers2

13

You were close to the correct way:

screen[1]:connect_signal("tag::history::update", function()
       mytagbox.text = awful.tag.selected(1).name
end)

-- Or add_signal on awesome < 3.5

So mytagbox.text will be changing on each tags switching.

mpe
  • 2,640
  • 1
  • 19
  • 17
Taras
  • 910
  • 7
  • 13
  • Thanks, I have put that code in my rc.lua and it half works - it displays the name of the first tag opened on login, but when I change tags after that, it doesn't update. I have written a function that returns `tagname`, but where should I make a call to that function in rc.lua so that it changes with the tags? Cheers – semiserious Jan 23 '12 at 00:15
  • You should just put `mytagbox.text = awful.tag.selected(1).name` into `tag::history::update` signal of screen[1]. I've updated example in my answer above. – Taras Jan 23 '12 at 01:34
  • For awesome 3.5 you should use "connect_signal" instead of add_signal, could you update your answer because this doesn't work anymore with awesome 3.5 and it doesn't generate any error.(it tooks me some time to figure out why this didn't work). – cedlemo Dec 12 '14 at 14:58
  • Awesome is now in its version 4.0, is this obsolete ? – Nikana Reklawyks Nov 09 '17 at 09:45
0

Another solution would be to change filter function on taglist

mytaglist[s] = awful.widget.taglist(s, function(t, args) return t.selected end, mytaglist.buttons)
barlik
  • 1
  • 1