The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
1

Invisible workspaces or scratchpad for entire workspaces

asked 2014-03-24 15:37:59 +0000

hbaughman gravatar image

I have a number of workspaces that I would like to be disappear when they are no longer the active workspace on a screen. In effect they would disappear just like empty workspaces disappear when you navigate away, though their contents would remain if you revisited them with their dedicated workspace switcher (bindsym $mod+1 workspace 1). They would not however be accessible by cycling with next_on_output. Ideally these clients would also be invisible on the the i3-status bar, though this is a optional consideration.

Another way of framing this is that I want a scratchpad for entire workspaces.

I think that this could be achieved with liberal use of i3-py (though I'm not sure it even includes every call I'd need). In any case it is horrifyingly kludgy.

on keypress exec
    if focus not on workspace
        go to workspace

        # i have a multi-head setup so focus might just have been on the other output
        if workspace is empty
            get client matching instance from scratchpad
            toggle float mode of client

    else
        verify that all clients in workspace have defined instance
        store all clients with said instance in scratchpad

        # does i3-py let you figure this out?
        # back_and_forth is the previously focused workspace
        if back_and_forth is on current output
            # causes the empty workspace now disappears
            workspace back_and_forth

        # i don't want to leave the now empty workspace open on that output
        else
            prev_workspace = back_and_forth
            # causes the empty workspace now disappears
            navigate to next_on_output
            # jumps focus back to previous output
            navigate to prev_workspace


# this seems like a particularly terrible idea!
with all requests to change workspaces exec
    temporary_workspaces = ["foo", "bar", "baz"]
    if workspace in temporary_workspaces is not active workspace on an output
        verify that all clients in that workspace have defined instance
        store all clients with said instance in scratchpad

Please, please, please tell me there is a better way to do that!

edit retag flag offensive close merge delete

Comments

1

This suggestion is untried and probably bogus. Maybe you could hide workspaces by moving them to an unused RandR monitor output such as VGA? In the userguide see: http://i3wm.org/docs/userguide.html#_moving_containers_workspaces_to_randr_outputs

KJ44 gravatar imageKJ44 ( 2014-03-25 17:57:18 +0000 )edit

@KJ44 Just tried it. Unfortunately it doesn't work if the output is disconnected, but definitely a clever idea. I'll see if I can trick my computer into thinking that VGA-1 is connected. In any case, I like how you think!

hbaughman gravatar imagehbaughman ( 2014-03-25 23:53:16 +0000 )edit
1

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-03-26 04:00:04 +0000

TonyC gravatar image

Here is an example from the new ipc project (you can find the latest file here). This uses the JavaScript version of the library but the same API is available in many languages. i3-py is not maintained and does not include many new features of i3wm.

I like the idea that was brought up in the comments about sending it another output better. Maybe I will work on that later.

#!/usr/bin/env gjs

/*
   This example shows how to implement a "hidden workspace" using the
   scratchpad. The workspace should "disapear" from i3bar when you switch
   away.

   Unfortunately, it cannot handle complex workspace layouts, and will make
   your scratchpad unusable for other things.

   https://faq.i3wm.org/question/3558/invisible-workspaces-or-scratchpad-for-entire-workspaces/
*/

const i3ipc = imports.gi.i3ipc;

let conn = new i3ipc.Connection;

const HIDDEN_WS = "5";
let scratchpad_len = 0;

conn.on('workspace::focus', function(conn, e) {
    if (e.current.name === HIDDEN_WS) {
        for (let i = 0; i < scratchpad_len; i += 1)
            conn.command('scratchpad show, floating disable');

        scratchpad_len = 0;
    } else if (e.old.name === HIDDEN_WS) {
        e.old.command_children('move scratchpad');

        scratchpad_len = e.old.nodes.length;
    }
});

conn.main();
edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-03-24 15:37:59 +0000

Seen: 385 times

Last updated: Mar 26 '14