The_Spectrwm_Window_Manager.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <html>
  2. <head>
  3. <title>The Spectrwm Window Manager</title>
  4. <link rel="stylesheet" href="main.css" type="text/css" />
  5. </head>
  6. <body>
  7. <center><h3>The spectrwm window manager</h3></center>
  8. <a href="https://opensource.conformal.com/wiki/spectrwm">The spectrwm
  9. window manager</a> was inspired by xmonad and <a href="dwm.html">dwm</a>. It shares several
  10. characteristics of dwm and has several nice features of its own, things
  11. that I always had to add to dwm with scripts or patches. The downside of
  12. that is that it's a bit bigger, with more dependencies, than dwm, but even
  13. on an old machine, it would be considered a very lightweight and fast
  14. window manager. <p>
  15. It was originally named scrotwm. Whether the humor was amusing, infantile,
  16. or both can be left to the judgement of the reader. Some people were
  17. offended and eventually the name was changed to spectrwm.<p>
  18. After installation, a default spectrwm.conf is created. If building from
  19. source, it will be in the spectrwm directory created after untarring the
  20. tarball. In Ubuntu based systems, as well as Fedora, it's /etc/spectrwm.conf.
  21. In FreeBSD it's /usr/local/etc/spectrwm.conf<p>
  22. Copy this file to your home directory.
  23. <table border="0" bgcolor="#E8E8E8">
  24. <tr>
  25. <td>
  26. <pre>
  27. cd
  28. cp /etc/spectrwm.conf .spectrwm.conf
  29. </pre>
  30. </td>
  31. </tr>
  32. </table>
  33. <p>
  34. Note the period before the name in your home directory. That's making it a
  35. hidden file. <p>
  36. The file is fairly straightforward and has pretty sane defaults. The key
  37. bindings are described in the man page. Between the descriptions in the
  38. file and the man page, even the newcomer shouldn't have much trouble. This
  39. page is to just touch upon some things said newcomer may overlook.<p>
  40. Like many tiling window managers, Mod1 (the alt key), shift, and return
  41. launches an xterm by default. Mod1 and p will launch dmenu, which, if you're
  42. not familiar with it, is a very handy little application--it will appear by
  43. default, at the top of the screen and you can enter the name of an
  44. application into it. It has automatic tab completion, so if you enter the
  45. first few letters of thunderbird, for example, it will complete the
  46. word--you can then hit enter and it will launch thunderbird.<p>
  47. The first window, on the left, is the master window. As you add other
  48. windows, they will open in a stack on the right, automatically sizing
  49. themselves so that they can fit. To swap a window with the master window,
  50. Mod1 and return will put the focused window on the left, as the main
  51. window. So, you might have a browser on the left and two or three
  52. terminals on the right. If you're doing something involved in one terminal
  53. and need more top to bottom space, give it focus, hit Mod1 and return, and
  54. it's in the master window. Some prefer that new windows open in the master
  55. position, and all currently open windows get moved to the stack column.
  56. (This is the default behavior of dwm, for example). In such a case, find
  57. the line in your $HOME/.spectrm.conf that reads
  58. <table border="0" bgcolor="#E8E8E8">
  59. <tr>
  60. <td>
  61. <pre>
  62. spawn_position = last
  63. </pre>
  64. </td>
  65. </tr>
  66. </table>
  67. <p>
  68. and change the word last to read first.<p>
  69. The <a href="https://github.com/conformal/spectrwm/wiki">home page</a> has
  70. some screenshots. <p>
  71. Hitting Mod1+l (lower case L) will expand the master window to the right.
  72. Hitting Mod1+h will shrink it to the left, or expand the stack on the
  73. right, depending upon your point of view. Those used to dwm will find the
  74. default keybindings fairly similar--using h and l to expand and contract
  75. the master are similar to movement keys in the vi editor. To focus on the
  76. next window use Mod1+j and Mod1+k moves to the previous window.<p>
  77. All of the above is common on many tiling window managers, but may help the
  78. novice as a 1 minute tutorial. Many people choose to customize their
  79. window manager, and this is where spectrwm shines, with a plain text
  80. configuration file and the ability to reload without restarting.<p>
  81. Let's start with the status bar. The default bar has more information than
  82. I need or want. I want the title of the focused window, the number of the
  83. workspace, and the date. Depending upon your version of spectrwm, you may
  84. have to manually add bar_format to your $HOME/.spectrwm.conf. A full
  85. description of the format is in the man page. To get what I want I use
  86. <table border="0" bgcolor="#E8E8E8">
  87. <tr>
  88. <td>
  89. <pre>
  90. bar_format =[+I] %R %F +C
  91. </pre>
  92. </td>
  93. </tr>
  94. </table>
  95. <p>
  96. The [+I] gives me the workspace number, and %R %F are the date format I
  97. prefer, giving me a time and date like 14:20 2014-11-14 (if it was 14:20 on
  98. the 14th of November in 2014, the day I'm writing this). The +C gives me
  99. the window class, which can be useful if I have a bunch of windows open.
  100. Spectrwm does identify the focused window by default, by having a 1 pixel
  101. red outline around it, but it can be useful to see it in the status bar as
  102. well. Some people prefer to have +W as well, for the window name. As far
  103. as I can see, if you have +C, +W or both in your bar_format line, you can
  104. leave the window_class_enabled and window_name_enabled at their default
  105. value of off. I haven't tested this too much, but it does seem that even
  106. if you turn them on, if you don't have the +C or +W in your bar_format
  107. line, you won't see a window name (or class) in the status bar.<p>
  108. One nice feature of spectrwm is that once you've changed your config file,
  109. MOD+q will reload it so that you can see your changes. (To quit spectrwm
  110. entirely use MOD+Shift+q). So, after making a change, hit MOD+q, and see
  111. if you like it. <p>
  112. A common change is the mod key. The default is Mod1, the alt key.
  113. Many people, including myself, prefer Mod4, the Windows key on a Windows
  114. keyboard, also known as Super. In your $HOME/.spectrwm.conf file, look for
  115. the line (like most defaults, it is commented out)
  116. <table border="0" bgcolor="#E8E8E8">
  117. <tr>
  118. <td>
  119. <pre>
  120. # modkey = Mod1
  121. </pre>
  122. </td>
  123. </tr>
  124. </table>
  125. <p>
  126. Change it Mod4 to have the Windows key be your usual mod key.<p>
  127. It has certain default programs--for example, the default terminal is
  128. xterm . You will see lines in your spectrwm.conf file like
  129. <table border="0" bgcolor="#E8E8E8">
  130. <tr>
  131. <td>
  132. <pre>
  133. program[term] = xterm
  134. </pre>
  135. </td>
  136. </tr>
  137. </table>
  138. <p>
  139. If you preferred urxvt, you can change xterm to urxvt.
  140. Its default binding is MOD+Shift+Return. To disable any default binding,
  141. look for the section Validated default programs. In the section below it,
  142. you can see examples of how to disable validation, just uncomment the
  143. default bind keys. In practice, if you specify another binding, this
  144. probably isn't necessary. For example, I prefer to open dmenu with
  145. MOD+Shift+p as I use MOD+p for firefox--a habit formed long, long ago, when
  146. it was called phoenix. Even if I don't uncomment the default MOD+p for
  147. dmenu, MOD+p still opens firefox if I have it defined in my
  148. .spectrwm.conf.<p>
  149. To bind a program to a key, you must first define it with a program line.
  150. For example, if I want to open firefox with a key command, I must first
  151. define the program. They give an example of firefox, opening it to the
  152. spectrwm home page. Suppose I just want open the opera browser with the
  153. key combo of MOD+o. I first give it a name with a program line, then open
  154. it.
  155. <table border="0" bgcolor="#E8E8E8">
  156. <tr>
  157. <td>
  158. <pre>
  159. program[opera] = opera
  160. bind[opera] = Mod+o
  161. </pre>
  162. </td>
  163. </tr>
  164. </table>
  165. <p>
  166. The program line is necessary. It can be quite useful to, for example, open
  167. a program with specificed defaults. For example, if I want open irssi in a
  168. specifically colored terminal
  169. <table border="0" bgcolor="#E8E8E8">
  170. <tr>
  171. <td>
  172. <pre>
  173. program[irc] = urxvt -bg black -fg white -e 'irssi -c irc.freenode.net'
  174. bind[irc] = MOD+i
  175. </pre>
  176. </td>
  177. </tr>
  178. </table>
  179. <p>
  180. (Either MOD or Mod will work.)<p>
  181. One very nice feature of spectrwm is that one can quickly, with the
  182. keyboard, toggle a window from tiled to floating and then, if it's
  183. floating, move it around and resize it. The keyboard shortcuts are in the
  184. man page, and can be added or changed in $HOME/.spectrwm.conf. MOD+t
  185. toggles the window to floating--then MOD+] moves it to right, MOD+[ to the
  186. left. MOD+- (the minus sign) shrinks the window's width. MOD+_ (the
  187. underscore, done with MOD+Shift+ the -_ key) shrinks the height. MOD+=
  188. increases the width and adding the Shift key, so that it's MOD++ (the plus
  189. sign) increases the height.<p>
  190. At work, I have 4 1600x900 monitors. I have NVidia cards and use the
  191. nvidia-settings program to make it run in Xinerama, one big screen. Using
  192. dwm, it seems to recognize screen boundries by default. With spectrwm,
  193. this should be configured in your .spectrwm.conf You will see a default
  194. commented out entry
  195. <table border="0" bgcolor="#E8E8E8">
  196. <tr>
  197. <td>
  198. <pre>
  199. region =screen[1]:1280x1024+0+0
  200. region =screen[1]:1280x1024+1280+0
  201. </pre>
  202. </td>
  203. </tr>
  204. </table>
  205. <p>
  206. This refers to the screen resolution, X (left to right) and Y (top to
  207. bottom) positions. So, as all my monitors are 1600x900 I use
  208. <table border="0" bgcolor="#E8E8E8">
  209. <tr>
  210. <td>
  211. <pre>
  212. region =screen[1]:1600x900+0+0
  213. region =screen[1]:1600x900+1600+0
  214. region =screen[1]:1600x900+0+900
  215. region =screen[1]:1600x900+1600+900
  216. </pre>
  217. </td>
  218. </tr>
  219. </table>
  220. <p>
  221. I'm not sure what that first [1] is for. The man page says idx but at any
  222. rate, in my setup, it stays at [1] for all of them. The first monitor, the
  223. upper left is at 0 and 0 that is, the far left and top edge of both X and Y
  224. axis. The second one is to the right, so it's at 1600 on the left to right
  225. axis and 0 on the Y axis. The third one is bottom left and so it's 0 for
  226. left to right and 900 on the Y axis and the last one, the bottom right,
  227. starts at 1600 on the left right axis and 900 at the up down axis. Some
  228. people may want larger regions, in which case they would make something
  229. like 3200x900+0+0. (To make one huge screen, I guess it would be 3200x1800,
  230. but in my case, I want each monitor to be a separate region.)<p>
  231. Each screen, when I do it this way, unlike dwm, has a different workspace
  232. number. If I have, for example firefox open on the top left, and
  233. thunderbird on the upper right, then, on the lower left, have something
  234. else, and then use MOD+2 on the lower left, it will now show me workspace
  235. 2, in other words, what was on the upper right monitor. The former
  236. workspace 2 will also change numbers. I've never actually kept track of
  237. this, as it only happens to me by mistake--generally what I want to do is
  238. open a fresh workspace, meaning I should use MOD+5, and hit 2 by mistake.
  239. Putting it back, by, while focused on the lower left monitor, doing
  240. MOD+3, puts all workspaces back to normal. MOD+Shift+number will moved a
  241. focused window to the workspace indicated by the number. In other words, if
  242. I want to move a terminal from workspace 3 to workspace 5, I focus on the
  243. terminal, hit MOD+Shift+5 and the terminal will now be on workspace 5.
  244. <p>
  245. With multiple monitors, you have to watch this--MOD+number won't switch
  246. focus to the screen with workspace 2, it will switch workspace 2 to the
  247. currently focused monitor. To move focus to a different monitor, the
  248. default key combination is MOD+&lt;number&gt; with the number being the
  249. keypad,rather than the number keys, which, as mentioned will switch the
  250. workspace within the monitor. The command is rg_n, with n referring to the
  251. number. One can also use rg_next and rg_previous. If you want, for
  252. example, to use MOD+N and MOD+P for next and previous regions (as MOD+p
  253. with lower case is already used)
  254. <table border="0" bgcolor="#E8E8E8">
  255. <tr>
  256. <td>
  257. <pre>
  258. bind[rg_next] = MOD+Shift+n
  259. bind[rg_prev] = MOD+Shift+p
  260. </pre>
  261. </td>
  262. </tr>
  263. </table>
  264. <p>
  265. On FreeBSD, I've found that one has to install x11/fonts/fonts-misc-misc.
  266. Otherwise, if I try to start spectrwm with startx, it fails to start,
  267. complaining about missing fonts. (I installed spectrwm with pkg, this may
  268. not be true with ports. On Fedora, I wasn't able to get the
  269. rpm to work in 21 beta, latest F23 (in TC status as I write this),
  270. everything is fine. On older versions If I installed
  271. the git version, it worked as expected. <p>
  272. In CentOS 6,x I'm not able to get anything later than version 2.5.1 to
  273. compile. To get it to work, after extracting the tarball, I have to edit
  274. the linux/Makefile. There is a line that begins LDADD+=. To get it to
  275. compile I have to edit it so that it reads
  276. <table border="0" bgcolor="#E8E8E8">
  277. <tr>
  278. <td>
  279. <pre>
  280. LDADD+= -lX11 -lX11-xcb -lxcb-aux -lxcb-icccm -lxcb-randr -lxcb-keysyms -lxcb-xtest -lXft -lXcursor
  281. </pre>
  282. </td>
  283. </tr>
  284. </table>
  285. <p>
  286. If your browser broke that, it should be on one line. In version 2.6 and
  287. above, the linux/Makefile doesn't have that line. The Makefile in the main
  288. directory has an LDADD line, but editing that didn't enable me to compile
  289. it. I should add that I have no knowledge of C, and it's possible that
  290. there's an easy fix, but with my relatively simple needs, version 2.5.1 is
  291. fine.
  292. <!--(FIXME--what about MOD+right and left)-->
  293. </body>
  294. <center><h2></h2></center><p>
  295. <center><script language="JavaScript">
  296. if (Date.parse(document.lastModified) > 0) {
  297. document.write ('<b>last modified: </b>' + document.lastModified +'<p>');
  298. }
  299. document.write('<b> url:</b>' + document.location.href + '</font><p>');
  300. </script>
  301. <hr width=60% align="center"><p>
  302. </body>
  303. </html>