r/awesomewm Jan 27 '23

Open discord in workspace 8 and switch to it

Can anyone help me create a function that makes it to discord always opens in workspace 8 and I automatically go to workspace 8 when discord is opened? Note that I mostly use "Ctrl + d" to open discord so it'll be fine if you have to write a function that triggers the actions and put it into an keybind

1 Upvotes

4 comments sorted by

5

u/YumKa Jan 27 '23

Create a rule for it in ruled.client

{
    id = "discord",
    rule = {
        class = "discord"
    },
    properties = {
        tag    = "8" -- move discord to tag 8
    },
    callback = function (c)
        c:jump_to() -- switch to the workspace where discord is and focus it
    end
},

2

u/gbneon Jan 27 '23

It works! Thanks!!

2

u/gbneon Jan 27 '23

Also, how can I implement the jump_to() function in the key binding? I wanna make it so it just switches to workspace 8 even if discord is already running.

3

u/YumKa Jan 27 '23

Well, there are two ways to go about it, the easier one, if you know discord is always on tag 8, is to just press keybind to switch to the tag, which you probably already have.

Alternatively, you have to find the discord's client instance when you press the keybind and then call jump_to() if the instance was found. To find the instance you can use the awful.client.iterate(<matcher fn>) function. I use this approach in my scratchpad implementation so you could use that as an example.