swm

sigma window manager
git clone git://wolog.xyz/swm
Log | Files | Refs | README | LICENSE

README (12948B)


      1 swm - Σ Window Manager
      2 ======================
      3 swm is [dwm](https://dwm.suckless.org) made less bare-boned and more
      4 customizable.
      5 
      6 
      7 Install & Run
      8 -------------
      9 libX11, libXft, and optionally libXinerama are required.  Edit config.mk
     10 to match your local setup, and then build and install swm with the
     11 following command (as root if necessary):
     12 
     13     make install
     14 
     15 The default installation directory is /usr/local/bin.
     16 
     17 You may add the following line to your .xinitrc to start swm using startx:
     18 
     19     exec swm
     20 
     21 But be warned that this new software might not yet be sufficiently
     22 crash-proof, so, for now, it's probably better to instead add something
     23 like this:
     24 
     25     swm || dwm
     26 
     27 This way a reliable window manager like dwm in this example can take
     28 over windows upon abnormal termination of swm.
     29 
     30 swm sends warnings and errors to stderr, so having its stderr logged
     31 might sometimes prove helpful.
     32 
     33 
     34 Quick Start
     35 -----------
     36 swm grabs any key with, by default, mod4 as a modifier, which is normally
     37 produced by the Super key.  This can be changed in config.h.  For the
     38 rest of the section Super is assumed to be the modifier key for swm.
     39 
     40 - Super+Enter: Spawn st, the suckless terminal.
     41 
     42 - Super+p: Launch other programs with dmenu.
     43 
     44 - Super+Backspace: Close the focused window.
     45 
     46 - Super+{j,k}: Focus the next/previous window.
     47 
     48 - Super+Shift+{j,k}: Shift the focused window.
     49 
     50 - Super+Space: Make the focused window the first.
     51 
     52 - Super+*n*: switch to the *n*th workspace.
     53 
     54 - Super+Shift+*n*: Tag the focused window with tag *n*; usually has the
     55   effect of sending the window to the *n*th workspace.
     56 
     57 - Super+{t,m}: Switch to the tiled (a.k.a. right stack) or monocle layout.
     58 
     59 - Super+y: Select from a list of layouts with dmenu; you can even make
     60   a new layout using this menu, but more on that later.
     61 
     62 - Super+{i,d}: Increase/Decrease the number of master area windows; if
     63   you don't already know the meaning, just try with a few windows in
     64   the default layout.
     65 
     66 - Super+{h,l}: Change the portion of master area.
     67 
     68 - Super+f: Toggle whether the focused window is fullscreen.
     69 
     70 - Super+Shift+{q,r}: Quit/Restart swm.
     71 
     72 If you use multiple monitors and don't disable Xinerama, these are
     73 also useful:
     74 
     75 - Super+], Super+[: Switch to the next/previous monitor.
     76 
     77 - Super+Shift+], Super+Shift+[: Send the focused window to the
     78   next/previous monitor.
     79 
     80 Using the mouse, you can press Super+Button1 to move a window and
     81 Super+Button3 to resize.  These will make the window floating.  You can
     82 press Super+Shift+Space to toggle the floating state of a window.
     83 
     84 More can be learnt from config.c.
     85 
     86 
     87 Configuration
     88 -------------
     89 config.c and config.h are provided for configuration.  Few options
     90 are contained in config.h, and everything else, including key bindings
     91 and colors etc. belong to config.c, a small separate compilation unit.
     92 This way rebuilding swm after changing key bindings etc. is much more
     93 efficient compared to dwm where changing any configuration requires
     94 recompilation of the whole program.
     95 
     96 Unlike dwm, key bindings are defined directly inside the key event
     97 handler, and mouse button bindings inside the button event handler,
     98 instead of arrays searched by the handlers.  This different approach is
     99 taken for greater flexibility.
    100 
    101 With keybindings defined directly in a function, it's complicated for swm
    102 to grab exactly the keys and buttons that are bound like dwm does, so,
    103 to be simple, swm grabs any key or button with the configured modifier,
    104 but this prevents the modifier from being shared with other graphical
    105 programs.  This issue is discussed next.
    106 
    107 
    108 Tips about Modifier Keys
    109 ------------------------
    110 The Alt key is probably the handiest modifier key on a typical keyboard,
    111 but using it with swm will prevent other graphical program from using it.
    112 You may do just that and live with the exclusiveness, or you may stick
    113 with using Super, which is generally not used by other graphical programs,
    114 if you don't mind the relative inconvenience; these are the two obvious
    115 options.  But here is a recommended third way: Turn Caps Lock into Super.
    116 
    117 You can turn Caps Lock into Super with this command:
    118 
    119     xmodmap -e 'remove Lock = Caps_Lock' \
    120             -e 'keysym Caps_Lock = Super_L Caps_Lock'
    121 
    122 This will still allow toggling all-caps by pressing Shift+Caps_Lock.
    123 Put the command in .xinitrc to automate it.
    124 
    125 If you also would like to use Caps Lock for Escape (sweet for vi users),
    126 do the two usages conflict?  They don't have to, with the help of
    127 [xcape](https://github.com/alols/xcape).  The following will make Caps
    128 Lock, now a surrogate Super key, function as Escape when pressed and
    129 released on its own:
    130 
    131     xcape -e Super_L=Escape
    132 
    133 xcape should be run after the xmodmap command.
    134 
    135 If xcape is used with xmodmap as described above, Shift+Caps_Lock will
    136 generate an Escape besides toggling all-caps.  You can fix that little
    137 problem by changing the xmodmap command above to this:
    138 
    139     xmodmap -e 'remove Lock = Caps_Lock' \
    140             -e 'keysym Caps_Lock = Super_L' \
    141             -e 'keysym Escape = Escape Caps_Lock'
    142 
    143 Be aware that there is a small issue with using Caps Lock as Super: Some
    144 keyboards have a problem with certain modifier combinations when using
    145 such a surrogate Super key.  So you might find it necessary to resort to
    146 the original Super key for, e.g., Super+Shift+2.  Modifier combinations
    147 are typically easier with the original Super key, anyway.
    148 
    149 
    150 Workspaces & Tags
    151 -----------------
    152 There are as many workspaces as there are tags.  You can select one
    153 workspace at a time, which contains a separate layout and a separate
    154 set of tags.  Every window can be assigned one or more tags just like
    155 in dwm, and a workspace's tag set is used to match windows by tags.
    156 Windows matched by the tag set of a workspace belong, non-exclusively,
    157 to the workspace.
    158 
    159 To compare, dwm has one layout and one tag set per (logical) monitor,
    160 and what feels sort of like switching between workspaces in dwm is
    161 actually setting the tag set to comprise only a specific tag.  You can
    162 put multiple tags in the tag set, but the selected tags are easily
    163 lost during switching between tags, making selecting multiple tags a
    164 less usable feature.  Besides, this design makes things like one layout
    165 "per tag" not quite well-defined.  So swm slightly enhanced the design to
    166 address these problems.  Initially, the tag set of each workspace contains
    167 a single tag that has the same index as the workspace, making selecting
    168 a workspace in swm works much like viewing a specific tag in dwm.
    169 
    170 The array of tags displayed on the status bar is dually used for tags
    171 and workspaces.  The current workspace is indicated by a bold underline,
    172 and the tag set of the workspace and tags of windows are indicated in
    173 the same way as indicated in dwm: Tags in the current tag set are colored
    174 differently, and tags that are applied to one or more windows are marked,
    175 in their upper left corner, by a little square, which is filled if the
    176 tag is applied to the focused window and empty otherwise.
    177 
    178 
    179 Restarting
    180 ----------
    181 Taking the dwm approach, you have to rebuild and restart swm for new
    182 configurations to take effect.  By default you can press Super+Shift+r
    183 to restart swm.  During restarting, swm executes the command that starts
    184 it and uses environment variables (later cleared by the new instance)
    185 to pass down certain runtime information, including:
    186 
    187 - The monitor each client belongs to
    188 - Order of clients in each monitor
    189 - Tags and state (floating/fullscreen/scratchpad) of each client
    190 - Tag set and layout in each workspace of each monitor
    191 - Whether gaps and bar are shown in each monitor
    192 - Each monitor's current workspace
    193 - The focused client
    194 
    195 These help provide a seamless transition and make reconfiguration like
    196 a breeze.
    197 
    198 
    199 Status Program
    200 --------------
    201 swm runs a status program configured in config.c and uses pipes to connect
    202 to the status program's input and output.  Every time the status program
    203 outputs a line, the line is taken as the new status text and displayed on
    204 the status bar.  swm talks to the status program by writing to its input.
    205 
    206 This is quite different from how dwm handles status.  dwm reads the
    207 WM_NAME property of the root window for status text.  This simplifies the
    208 window manager's main loop, but makes it uneasy for the window manager
    209 to talk to the status program, adds a little burden to the status program
    210 and is less efficient.
    211 
    212 swm recognizes status text as blocks separated by two or more consecutive
    213 spaces.  When a block displayed on the status bar is clicked, swm's
    214 button event handler by default writes to the status program a line
    215 indicating which block is clicked (1 for the rightmost, 2 for the second
    216 rightmost, etc.), which button is pressed, and which modifiers are on.
    217 Details of what gets written can be found or changed in config.c.
    218 
    219 The status program can be toggled on and off with Super+Shift+s by
    220 default.  Pressing the key twice has the effect of restarting the status
    221 program.  By turning the status program off, swm doesn't directly kill
    222 it but closes the pipe to its input, and the status program is expected
    223 to detect this condition.
    224 
    225 The status program that swm by default is configured to use is
    226 [infobar](https://wolog.xyz/repos/infobar).
    227 
    228 
    229 Scratchpads
    230 -----------
    231 Scratchpads are windows, typically floating and centered, that can be
    232 handily brought into and out of view.  In swm, any window can be marked
    233 a scratchpad.  Here are the related default key bindings:
    234 
    235 - `Super+'`: Toggle a scratchpad.  If visible scratchpads are present,
    236   the topmost is hidden; otherwise, the topmost hidden scratchpad
    237   (normally the most recently used) is brought into view.  If there is
    238   no scratchpad at all, a scratchpad terminal is launched.
    239 
    240 - `Super+.`: Cycle through all hidden scratchpads.  If the focused window
    241   is a scratchpad, it gets replaced by the next hidden scratchpad, if
    242   any; otherwise this just brings a hidden scratchpad, if there is one,
    243   into view.
    244 
    245 - Super+Shift+Enter: Launch the scratchpad terminal.
    246 
    247 - Super+<backtick>: Toggle whether a window is a scratchpad or not.
    248   A floating window gets centered when turned into a scratchpad.
    249 
    250 The basic usage is simply to toggle a scratchpad terminal on and off
    251 by pressing `Super+'`, but you're offered convenience to develop more
    252 sophisticated usages.
    253 
    254 
    255 Layout Description Language
    256 ---------------------------
    257 The layout description language is a tiny language invented for
    258 specification of layouts in swm.  Most layouts that can be found in
    259 dwm and its patches can be described quite well in this language. Here
    260 are examples:
    261 
    262 - Right stack (the default tiled layout):
    263 
    264     [*]:.55 []
    265 
    266 - Monocle:
    267 
    268     ()
    269 
    270 - Deck:
    271 
    272     [*]:.55 ()
    273 
    274 - Bottom stack:
    275 
    276     [{*}:.55 {}]
    277 
    278 - Fibonacci spiral:
    279 
    280     .62 [.62 -{.62 [.62 ()]}]
    281 
    282 - Fibonacci dwindle:
    283 
    284     .62 [.62 {.62 [.62 ()]}]
    285 
    286 (The last two examples are not actually exact, as the actual layouts
    287 described will tile the 5th and subsequent windows in the monocle manner.)
    288 
    289 dwm's notions of master number and master factor are defined more
    290 generically in swm.  Generally, changing them in swm works the way most
    291 dwm users would expect.
    292 
    293 The language is simple enough that you can probably gain intuition
    294 from the examples and then figure it out by experimenting (see the next
    295 section for an easy method).
    296 
    297 
    298 dmenu Integration
    299 -----------------
    300 First of all, in case you only think of dmenu as a fuzzy single-item
    301 selector: You can pick multiple items, and even pick an item multiple
    302 times, with Ctrl+Enter while navigating the menu using Ctrl+{n,p}; you
    303 can also use dmenu as an input box, where Tab can be used to copy an
    304 item, a bit of line editing capability is available, and the input can
    305 be confirmed by pressing Shift+Enter.
    306 
    307 In swm, by default, pressing Super+y runs dmenu to give you a menu of
    308 layout descriptions to choose from, where you may also write an ad-hoc
    309 layout or tweak an existing one.
    310 
    311 swm provides four types of gaps (internal/outer, horizontal/vertical) that
    312 are separately settable.  Pressing Super+g gives you a menu of options for
    313 setting or changing the values of them, where making good use of dmenu
    314 will enable you to easily tune them. (But if you just want to toggle
    315 gaps off, press Super+Shift+g, and if you want to increase or decrease
    316 all gaps, scroll up and down with your mouse while holding Super.)
    317 
    318 vanitygaps, a dwm patch, offers a number of layouts with gaps, but to
    319 fully utilize what it offers, a user would need to bind eight keys each for
    320 choosing one layout and bind eight keys for increasing and decreasing the
    321 four types of gaps.  This is a waste of spare keys given the infrequency
    322 of most of the actions, and even that doesn't provide as much freedom as
    323 swm does.  So swm's menus serve to help out such situations by combining
    324 many infrequent actions into few menus and allowing doing things more
    325 sophisticated in case of need.
    326 
    327 You can easily construct such menus in config.c using convenience
    328 functions provided; see config.c for examples.