Launcher auto-hiding

If you use launchers you may want if an application started, its launcher will be hide, so you can't start the application twice with a "random mouse click".

I'm using a lua-table to store my launchers.

Concretely I've two launchers, launchers["Qbittorrent"] and launchers["Chromium"]. The keys are the client's class name (because of simplicity).

So, here is the codes.

This function checks the clients and launchers. If there is a client from a launcher, the launcher will unset (nil). function get_launchers_table tmp_launchers = awful.util.table.clone(launchers) local clients = client.get(0) for _,client in pairs(clients) do       if (launchers[client.class]~=nil) then tmp_launchers[client.class] = nil end end local ret = {} local x,y for x,y in pairs(tmp_launchers) do       if (y~=nil) then table.insert(ret,x) end end return ret end

This is a simple util: checks if what is in table. function in_table(table,what) local item for _,item in pairs(table) do       if (what==item) then return true end end return false end

Checks if table t1 has same elements as table t2. function table_equal(t1,t2) if (t1==nil) then return false end if ( #t1 ~= #t2 ) then return false end local item for _,item in pairs(t1) do       if (not in_table(t2,item)) then return false end end return true end

Set the wiboxes["bottom_right"] wibox's widgets. If the client list does not change (previous value stored in launchers_to_wibox.

launchers_to_wibox = {} function set_wibox_widgets local tmp = get_launchers_table if (table_equal(tmp,launchers_to_wibox)) then return end wiboxes["bottom_right"].widgets = {} local x   local nr = 0 for _,x in pairs(tmp) do       nr = nr+1 wiboxes["bottom_right"].widgets[nr] = launchers[x] end wiboxes["bottom_right"].widgets.layout = awful.widget.layout.horizontal.rightleft launchers_to_wibox = tmp end

You can add a timer object with function set_wibox_widgets.

Enjoy!