Package: qtile-mutable-scratch
qtile MutableScratchThis package is a series of functions and a class to create a "scratch" space
in qtile more similar to i3's. qtile has theScratchPadgroup type, but the
(documented) purpose is to only hostDropdownwindows that must be specified
ahead of time.Instead, whatMutableScratchdoes is piggybacks onto an "invisible" qtileGroup(ie. a group named'') and provide functions to dynamically add and
remove windows to this group. Viewing the "hidden" windows is done via a toggle
function, which cycles through the windows in the Scratch group. All windows
added to theMutableScratchgroup will be automatically converted to
floating. This emulates the scratch functionality of i3 as closely as possible.Seerepository README for most up-to-date documentation.InstallationYou can now install viapip:pip install qtile_mutable_scratchSetupPut the following default configuration in yourconfig.py:importqtile_mutable_scratchfromlibqtile.configimportEzKeyfromlibqtileimporthook...mutscr=qtile_mutable_scratch.MutableScratch()groups.append(Group(''))# Must be after `groups` is createdkeys.extend([EzKey('M-S-<minus>',mutscr.add_current_window()),EzKey('M-C-<minus>',mutscr.remove_current_window()),EzKey('M-<minus>',mutscr.toggle()),])hook.subscribe.startup_complete(mutscr.qtile_startup)EachMutableScratchinstance has two parameters to chose from,scratch_group_nameandwin_attr.
It's not necessary to set these, as the default configuration
should work for every configuration.scratch_group_name(default'', or the empty name group) sets the name of the group that will old the scratch windows.win_attr(defaultmutscratch) sets the attribute that will be set on each window to tag it as being apart of theMutableScratchsystem.UsageAdd the current window to theMutableScratchgroup viaMutableScratch.add_current_window()This will move the window to the invisible groupRotate through windows in theMutableScratchgroup viaMutableScratch.toggle()If the current window is apart of theMutableScratchgroup, then it will be moved back to the invisible groupIf the current window is not apart of theMutableScratch, then the nextMutableScratchwindow in the stack will be moved to the current groupTo remove a window from theMutableScratchgroup, useMutableScratch.remove()Hastily thrown together demo video:It's ugly, but it get's the point across...hopefully.https://user-images.githubusercontent.com/20801821/147259912-5acec613-239b-4fe3-aebb-9c1820426d2c.mp4Implementation DetailsTracking members of theMutableScratchgroupThis is done by dynamically adding an attribute (by defaultmutscratch) to
the window object that simply stores a boolean.Cycling through windows inMutableScratchMutableScratchhas something similar to qtile'sfocus_historyfor groups.
It's effectively just a stack of windows belonging to theMutableScratchgroup, where windows are pushed and popped from the stack.
Doing this,MutableScratchcontrols the order in which the windows are stored in the stack.
This ensures that the every window in theMutableScratchgroup can be accessed via toggle.Initializing theMutableScratchon qtile startWhen restarting qtile, theMutableScratchinstance inconfig.pywill be overwritten, losing the stack history and the floating window status of it's windows.
To stop this, we add ahookfunction tostartup_completethat will reinitialize a newMutableScratchinstance with the windows that are located in theMutableScratch.scratch_group_name.