1

In awesome window manager, I want to create a shortcut to toggle show dekstop (like modkey + d)

I i press ModKey + d then it should show destop and again i press Modkey + d it should show the windows like previously

Is this possible

Santhosh
  • 9,965
  • 20
  • 103
  • 243
  • The easiest way might to deselect all tags to show the desktop (but sticky clients (clients visible on all tags) would then still be visible; is this a problem for you?). – Uli Schlachter Jan 25 '20 at 09:03
  • No problem if sticky clients are shown. – Santhosh Jan 25 '20 at 13:02
  • Not much time to test right now, but I think `awful.tag.viewnone(s)` should make the screen visible on screen `s` and `awful.tag.history.restore(s)` should make clients visible again. But I am not totally sure that the restore works and perhaps it needs to be `restore(s, 0)` or `restore(s, 1)` or something like that.... – Uli Schlachter Jan 25 '20 at 20:24

2 Answers2

0

In your rc.lua set the following:

local show_desktop = false

then in globalkeys = gears.table.join( add:

-- Toggle showing the desktop
awful.key({ altkey, "Control" }, "d",
    function(c)
        if show_desktop then
            for _, c in ipairs(client.get()) do
                c:emit_signal(
                    "request::activate", "key.unminimize", {raise = true}
                )
            end
            show_desktop = false
        else
            for _, c in ipairs(client.get()) do
                c.minimized = true
            end
            show_desktop = true
        end
    end,
    {description = "toggle showing the desktop", group = "client"}),

I use ctrl+alt+d but you can replace the above with awful.key({ modkey }, "d", if preferred.

Here is a link to my Reddit post about this as well.

jbrock
  • 111
  • 3
0

This is what I once used to do so (borrowed from here), although I remember it messed up the arrangement of clients/windows:

awful.key({ M }, "d", function()
    local tags = awful.screen.focused().tags
    for i = 1, 2 do tags[i].selected = false end end,
    create_description("show", "desktop")),

awful.key({ M, S }, "d", function()
    local tags = awful.screen.focused().tags
    for i = 1, 2 do tags[i].selected = true end end,
    create_description("unshow", "desktop")),
nino
  • 554
  • 2
  • 7
  • 20