[HOME] [BASH] [Window Managers]

Avoiding dependencies

"I've always lived cheaply. I live like a student, basically. And I like that because it means that money is not telling me what to do. I can do what I think is important for me to do. It freed me to do what seemed worth doing. So make a real effort to avoid getting sucked into all of the expensive lifestyle habits of typical Americans ... because, if you do that, then the people with the money will dictate what you do with your life. You won't be able to do what's really important to you." -- Ritchard M. Stallman.

Unfortunately, in 1987 I had to do the compulsory military service (In Argentina, my country, it was abolished in 1994). A pair of days before christmas, four of us were on duty. We must stay four hours sitting in a room like reinforcement in case of emergency(!?).

In the calmly of the night the young officer in charge asked us, one by one, the typical: What would you do with the big prize of christmas lottery?

At this time (I was nineteen) my companions and me thought that we were just losing fourteen months of our lives. Now, with half life's experience on my back, I realized that it was just one of the lot of arbitrary stupid things that society forces individuals to do. Now I don't see a big difference between military service and school, neighborhood or family. I've received worse abuses from teachers, neighbors, friends, relatives than from sergeants or captains. Violence is spontaneous, natural, explicit. High-handedness is, the most of the times, subliminal, innocent.

And people support these abuses because don't dare to find out to what extent really depend on all this stuff.

With the same assurance the young version of me added another 'life of luxury' to other's descriptions I know exactly what I would answer to the officer if I could go back to this instant of my life: "I would buy a little house in a quiet place, far from all towns, and I would refrain from squandering".

With GNU/Linux a window manager
is enough

Between others you can use Icewm, Window Maker or Fluxbox.

Now I use Sawfish (it is written in lisp) with fbpanel.

Fonts

What is priority in graphical interfaces? If you 'use' your machine surely your answer is: a good font rendering.

So first of all, I will explain how I configure fonts. I'd set dpi to 96 but you may preffer 100 or other value depending on the size of your screen (you may take a look here to choose the correct dpi). Generally it is not necessary to set dpi in all three files (~/.fonts.conf, ~/.Xdefaults and ~/.xserverrc) but doing so you will be sure all apps are covered.

Create ~/.xserverrc and add dpi resolution:

#!/bin/sh
#
## ~/.xserverrc
#

exec /usr/bin/X11/X -br -dpi 96 -nolisten tcp

## End

Create ~/.fonts.conf:

<!-- ~/.fonts.conf -->
<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>

  <match target="pattern">
    <edit name="dpi" mode="assign">
      <double>96</double>
    </edit>
  </match>

  <match target="font" >
    <edit mode="assign" name="rgba" >
      <const>none</const>
    </edit>
  </match>

  <match target="font" >
    <edit mode="assign" name="hinting" >
      <bool>true</bool>
    </edit>
  </match>

  <match target="font" >
    <edit mode="assign" name="hintstyle" >
      <const>hintslight</const>
    </edit>
  </match>

  <match target="font" >
    <edit mode="assign" name="antialias" >
      <bool>true</bool>
    </edit>
  </match>

  <match target="font">
    <edit name="autohint" mode="assign">
      <bool>true</bool>
    </edit>
  </match>

</fontconfig>
<!-- End .fonts.conf -->

You can copy the file to /etc/fonts/local.conf so fonts on applications opened like super user will look the same than others.

# cp /home/user/.fonts.conf /etc/fonts/local.conf

Finally include this to your ~/.Xdefaults. Specially important are the Xft variables. This will correct all window managers and some new desktop environments like LXDE.

!
!! ~/.Xdefaults
!

!! Xft variables.  (Apps opened by root: if it is your machine
!! make a soft link in /root/.Xdefaults)
Xft.antialias: 1
Xft.hinting: 1
Xft.hintstyle: hintslight
Xft.rgba: none
Xft.dpi: 96

!! Other staff that could be usefull

!! XTerm
*xterm*faceName: monospace
*xterm*faceSize: 12
*xterm*faceSize1: 8
*xterm*faceSize2: 9
*xterm*faceSize3: 10
*xterm*faceSize4: 12
*xterm*faceSize5: 14
*xterm*faceSize6: 16

*xterm*metaSendsEscape: true
*xterm*eightBitInput: false
*xterm*saveLines: 2500

*xterm*VT100*colorAttrMode: on
*xterm*VT100*underLine: off
*xterm*VT100*italicULMode: on
*xterm*VT100*color1: tomato
*xterm*VT100*color9: red

!! URXvt
urxvt.font: xft:monospace-10
urxvt.letterSpace: -1
urxvt.scrollBar: False
urxvt.intensityStyles: False

!! Emacs
emacs.font: monospace:pixelsize=14
!emacs.background: gray20
!emacs.foreground: gray60
!emacs.cursorColor: #aaa
!emacs.pointerColor: white
emacs.toolBar: 0
!emacs.menuBar: 0
emacs.verticalScrollBars: right
!emacs.geometry: 80x30

!! Xpdf
!xpdf.initialZoom: width
!xpdf.viKeys: True

!! Xdvi
!xdvi*mfMode: ljfour:600
!xdvi*expertMode: 3

!! Xboard (The only game I like)
xboard.boardSize: small

!! End of ~/.Xdefaults

Unified keybindings

Other reason to avoid desktop environments is key bindings. Have you ever seen anybody using Alt+<key> to access a graphical interface menu? It could be useful just in case your mouse doesn't work. Besides, MSWindows and MacOS like interfaces are overloaded of icons, tooltips, popup dialogs just for avoid users not even imagine leave the mouse. Let's thank GNU/Linux desktop developers that 'at least' konsole, gnome-terminal, xfce-term, etc. include in preferences an option to disable those stupid Alt+key menu bindings. No, I am not an Emacs fanatic. I like Unix simplicity and, with the exception of the overloaded Emacs editor itself, I consider GNU versions a sensible 'moderate' step beyond humanization at several, and all important, abstraction levels.

It doesn't care if emacs, vi or whatever key binding you like, but having for goal an 'unified' set. Taking in care that 'unified' doesn't mean the 'exactly' same behavior in all apps; in some cases 'different' (or, more suitable said, 'complementary') key bindings avoid problems between two applications that must live together. Window managers are the better example of that.

This is a slightly modified emacs gtkrc. You may append it to your ~/.gtkrc-2.0.mine).

#
## ~/.gtkrc-2.0.mine -- Emacs-like keybindings
#
## Add 'include "/home/morlock/.gtkrc-2.0.mine"' to ~/.gtkrc-2.0.
#
## (To disable the fucking Alt key in firefox set the
## "ui.key.menuAccessKey" variable to "0")

binding "gtk-emacs-text-entry"
{
  bind "<ctrl>b" { "move-cursor" (logical-positions, -1, 0) }
  bind "<ctrl>f" { "move-cursor" (logical-positions, 1, 0) }

  bind "<alt>b" { "move-cursor" (words, -1, 0) }
  bind "<alt>f" { "move-cursor" (words, 1, 0) }

  bind "<ctrl>a" { "move-cursor" (paragraph-ends, -1, 0) }
  bind "<ctrl>e" { "move-cursor" (paragraph-ends, 1, 0) }

  bind "<ctrl>w" { "cut-clipboard" () }
  bind "<ctrl>y" { "paste-clipboard" () }

  bind "<ctrl>d" { "delete-from-cursor" (chars, 1) }
  bind "<alt>d" { "delete-from-cursor" (word-ends, 1) }
  bind "<alt>BackSpace" { "delete-from-cursor" (word-ends, -1) }
  bind "<ctrl>k" { "delete-from-cursor" (paragraph-ends, 1) }

  bind "<ctrl>u" { "delete-from-cursor" (paragraph-ends, -1) }
  bind "<ctrl>h" { "delete-from-cursor" (chars, -1) }
  bind "<ctrl>w" { "delete-from-cursor" (word-ends, -1) }
}

binding "gtk-emacs-text-view"
{
  bind "<ctrl>p" { "move-cursor" (display-lines, -1, 0) }
  bind "<ctrl>n" { "move-cursor" (display-lines, 1, 0) }

  bind "<ctrl>space" { "set-anchor" () }
  bind "<ctrl>KP_Space" { "set-anchor" () }
}

binding "gtk-emacs-tree-view"
{
  bind "<ctrl>s" { "start-interactive-search" () }
  bind "<ctrl>f" { "move-cursor" (logical-positions, 1) }
  bind "<ctrl>b" { "move-cursor" (logical-positions, -1) }
}

binding "gtk-emacs-menu"
{
  bind "<ctrl>n" { "move-current" (next) }
  bind "<ctrl>p" { "move-current" (prev) }
  bind "<ctrl>f" { "move-current" (child) }
  bind "<ctrl>b" { "move-current" (parent) }
}

class "GtkEntry" binding "gtk-emacs-text-entry"
class "GtkTextView" binding "gtk-emacs-text-entry"
class "GtkTextView" binding "gtk-emacs-text-view"
class "GtkTreeView" binding "gtk-emacs-tree-view"
class "GtkMenuShell" binding "gtk-emacs-menu"

Comfortably navigating a PDF file:

#
## ~/.xpdfrc
#
## Vi keybindings
bind l any scrollLeft(16)
bind h any scrollRight(16)
bind k any scrollUp(16)
bind j any scrollDown(16)

## Emacs keybindings
bind ctrl-b any scrollLeft(16)
bind ctrl-f any scrollRight(16)
bind ctrl-p any scrollUp(16)
bind ctrl-n any scrollDown(16)
bind alt-v any scrollUpPrevPage(900)
bind ctrl-v  any scrollDownNextPage(900)
bind alt-<  any gotoPage(1)
bind alt->  any gotoLastPage
bind ctrl-s any find
bind ctrl-+ any zoomIn
bind ctrl-- any zoomOut

Let's go

I cosider startx the best choice; X will run like a client of 'your' shell process and you will have control over it (to have 'control' over the software I run is the principal reason I use free software).

#
## ~/.xinitrc
#

## Install `xli' and put here the path to your desktop background.
xli -onroot .twm/fondo.xpm &

## If you will use TWM comment this line.
fbpanel &

#twm
sawfish

## End ~/.xinitrc

And Sawfish:

;; ~/.sawfishrc -- Walter Alejandro Iglesias.
(require 'sawmill-defaults)

;; I'd defined running applications like functions and included below
;; in global-keymap keybindings.
(defun emacs () (interactive) (system "emacs &"))
(defun rxvt () (interactive) (system "urxvt &"))
(defun iceweasel () (interactive) (system "iceweasel &"))
(defun gimp () (interactive) (system "gimp &"))
(defun mutt () (interactive) (system "urxvt -e mutt &"))
(defun alsamixer () (interactive) (system "urxvt -e alsamixer &"))

;; Keybindings.
(bind-keys
 global-keymap
 "M-TAB"                'cycle-windows
 "M-F2"                 'run-shell-command
 "M-F4"                 'delete-window
 "F11"                  'maximize-window-fullscreen-toggle
 "M-F11"                'maximize-window-toggle
 "M-F10"                'maximize-window-vertically-toggle
 "M-F12"                'maximize-window-horizontally-toggle
 "M-F9"                 'toggle-window-shaded
 "M-F8"                 'toggle-window-iconified
 "C-M-Right"            'next-workspace
 "C-M-Left"             'previous-workspace
 "H-Space"              'call-command
 "H-j"                  'emacs
 "H-n"                  'iceweasel
 "H-u"                  'rxvt
 "H-Button4-Click"      '(system "amixer sset Master,0 5+ &")
 "H-Button5-Click"      '(system "amixer sset Master,0 5- &")
 "H-Up"                 '(system "amixer sset Master,0 5+ &")
 "H-Down"               '(system "amixer sset Master,0 5- &")
 )

;; Mouse click on window.
(bind-keys
 window-keymap
 "Button1-Click"        'raise-and-pass-through-click
 "M-Button1-Move"       'move-window-interactively
 "M-Button2-Click"      'popup-window-menu
 "M-Button3-Click"      'resize-window-interactively
 "M-Down"               'lower-window
 "M-Up"                 'raise-window
)

;; Mouse click on root window.
(bind-keys
 root-window-keymap
 "Button3-Click" 'popup-root-menu
 "Button5-Click" 'workspace-right
 "Button4-Click" 'workspace-left
)

;; Mouse click on window title.
(bind-keys
 title-keymap
 "Button1-Move"  'move-window-interactively
 "Button3-Click" 'popup-window-menu
 "Button4-Click" 'shade-window
 "Button5-Click" 'unshade-window
 "Button1-Off2"  'maximize-window-toggle
 "Button2-Move"  'resize-window-interactively
 "Button3-Off"   'raise-lower-window
 )

;; Mouse click on window border.
(bind-keys
 border-keymap
 "Button1-Move" 'resize-window-interactively
 )

;; Drag windows across workspaces.
(require 'sawfish.wm.ext.edge-flip)
(define-special-variable edge-flip-enabled t
  "Select the next desktop when the pointer hits screen edge.")
(define-special-variable edge-flip-type 'workspace
  "Control what hitting the screen edge selects, workspace or viewport.")
(define-special-variable edge-flip-only-when-moving t
  "Only flip when interactively moving a window.")
(define-special-variable edge-flip-delay 100
  "Milliseconds to delay before edge flipping.")
;; End ~/.sawfishrc

Or, if you prefer:

#
## ~/.twmrc -- Walter A. Iglesias.  (For debian menu read the note at
## bottom).
#

#
## General options
#
ButtonIndent 0
NoGrabServer
NoRaiseOnMove
NoRaiseOnResize
BorderWidth 2
DecorateTransients
ConstrainedMoveTime 0
RandomPlacement
TitlePadding 6
OpaqueMove
WarpUnmapped
NoStackMode
NoSaveUnders
RestartPreviousState
AutoRelativeResize
DontMoveOff
ShowIconManager
IconifyByUnmapping
UsePPosition "on"

# Adjust the following to your screen resolution.  Rest 56px to the
# hight if you wish maximizated windows don't cover icon manager.
MaxWindowSize "1680x1050"
IconManagerGeometry "=1680x26+0-0" 8

#
## Fonts
#
TitleFont "-misc-fixed-medium-r-normal--18-*-100-100-c-90-iso10646-1"
ResizeFont "-misc-fixed-medium-r-normal--18-*-100-100-c-90-iso10646-1"
MenuFont "-misc-fixed-medium-r-normal--18-*-100-100-c-90-iso10646-1"
IconFont "-misc-fixed-medium-r-normal--18-*-100-100-c-90-iso10646-1"
IconManagerFont "-misc-fixed-medium-r-normal--18-*-100-100-c-90-iso10646-1"

#
## Colors
#
Color
{
  BorderColor            "gray34"
  MenuBorderColor        "gray34"
  IconBorderColor        "gray34"

  DefaultBackground      "gray34"
  TitleBackground        "gray34"
  MenuBackground         "gray34"
  IconBackground         "gray34"
  IconManagerBackground  "gray34"
  MenuTitleBackground    "white"

  BorderTileBackground   "gray34"
  BorderTileForeground   "gray34"

  DefaultForeground      "white"
  TitleForeground        "white"
  MenuForeground         "white"
  IconForeground         "white"
  IconManagerForeground  "white"
  MenuTitleForeground    "gray34"

  IconManagerHighlight   "green"
  MenuShadowColor        "white"
}

## Don't draw title bar to these apps.
NoTitle { "XClock" "xosview" "xbiff" "xload" "TWM Icon Manager" }

## Don't show these apps at icon manager.
IconManagerDontShow { "XClock" "xosview" "xbiff" }

DefaultFunction f.nop

## Defining functions.
MoveDelta 7
Function "move-or-raiselower" { f.move f.deltastop f.raiselower }
Function "move-or-iconify"    { f.move f.deltastop f.iconify }
Function "resize-or-fullzoom" { f.resize f.deltastop f.fullzoom }
Function "deiconify-n-raise"  { f.deiconify f.raise }

## Mouse click.

Button1 = : root : f.menu "main"
Button3 = : root : f.menu "windowops"
Button2 = : root : f.menu "TwmWindows"

Button1 = : t|f : f.function "move-or-raiselower"
Button3 = : title : f.menu "windowops"

Button1 = m : w : f.function "move-or-raiselower"
Button3 = m : w : f.resize

Button1 = : iconmgr : f.function "deiconify-n-raise"
Button3 = : iconmgr : f.iconify

## Redmont's like title bar buttons.
NoDefaults
RightTitleButton ":dot" = f.iconify
RightTitleButton ":resize" = f.function "resize-or-fullzoom"
RightTitleButton ":xlogo" = f.delete

#
## Key bindings
#
# windows
# Add to this list windows that you want cicle with 'Alt-Tab'.
WindowRing {
  "root"
  "UXTerm"
  "XTerm"
  "Emacs"
  "Firefox-bin"
  "MPlayer"
  "Inkscape"
  "Gimp"
  "GV"
  "XDvi"
  "Xpdf"
  "Acroread-en"
  "Synaptic"
}

"Menu" =   	: all : f.warpto "UXTerm"
"Tab"  = m 	: all : f.warpring "next"    # Defined at 'WindowRing'.
"Tab"  = m | s 	: all : f.warpring "prev"
"F11"  = m 	: all : f.fullzoom
"F12"  = m 	: all : f.hzoom
"F10"  = m 	: all : f.zoom
"F8"   = m 	: all : f.iconify
"F4"   = m 	: all : f.delete

# programs
"F2" = m    : all : !"/usr/bin/gmrun $amp;"
"u"  = mod4 : all : !"/usr/bin/uxterm &"
"n"  = mod4 : all : !"/usr/bin/iceweasel &"
"e"  = mod4 : all : !"/usr/local/bin/emacs &"
"p"  = mod4 : all : !"/usr/bin/su-to-root -X -c /usr/sbin/synaptic &"
"m"  = mod4 : all : !"uxterm -T \"Mutt\" -e sh -c \"/usr/bin/mutt\" &"

#
## Menus
#
menu "main"
{
  "Menu"              f.title
  "XTerm (Win+u)"     ! "/usr/bin/uxterm &"
  "Firefox (Win+n)"   ! "/usr/bin/firefox &"
  "Emacs (Win+e)"     ! "/usr/local/bin/emacs &"
  "Mutt (Win+m)"      ! "uxterm -T \"Mutt\" -e sh -c \"/usr/bin/mutt\" &"
  "Synaptic (Win+p)"  ! "/usr/bin/su-to-root -X -c /usr/sbin/synaptic &"
  ""                  f.nop
  "Programs"          f.menu "/Debian"     # See the comment at the end.
  ""                  f.nop

  "Show Icon bar"     f.showiconmgr
  "Hide Icon bar"     f.hideiconmgr

  ""                  f.nop
  "Exit"              f.menu "Quit-Verify"
}

menu "Icon bar"
{
  "Show"              f.showiconmgr
  "Hide"              f.hideiconmgr
}

menu "Quit-Verify"
{
  "Restart TWM"       f.restart
  "Exit"              f.quit
}

menu "windowops"
{
  "Window Ops"              f.title
  "Maximize (Alt+F11)"      f.fullzoom
  "H. Maximize (Alt+F12)"   f.hzoom
  "V. Maximize (Alt+F10)"   f.zoom
  "Iconify (Alt+F3)"        f.iconify
  "Resize"                  f.resize
  "Move"                    f.move
  "Raise"                   f.raise
  "Lower"                   f.lower
  "Identify"                f.identify
  ""                        f.nop
  "Focus"                   f.focus
  "Unfocus"                 f.unfocus
  ""                        f.nop
  "Close (Alt+F4)"          f.delete
  "Kill"                    f.destroy
}

## In twmrc file `include' doesn't work.  So to get debian menu
## updated exists two workarounds:
#
## 1) Append here the part of "~/.twm/system.twmrc" generated by
## `update-menus'.  It will appear in Programs submenu.
#
## 2) If you don't share the system with other users add these
## customizations to `/etc/X11/twm/system.twmrc-menu' and uncomment
## the following:
#include-menu-defs

## At home, I move `~/.twmrc' to `~/.twm/rc' and make
## `/etc/X11/twm/system.twmrc-menu' a soft link pointing to
## `~/.tmw/rc'; so I add my customizations to my home rc file, and
## running update-menus I get the submenu automatically updated.

## End ~/.twmrc
#

<= Previous



[HOME] [BASH] [Window Managers]

You can mail me to eloi at roquesor.com.