Added xmonad stuff

This commit is contained in:
Josh Sherman 2012-03-10 16:10:22 -05:00
parent 29b8216e89
commit 92b936d948
12 changed files with 687 additions and 0 deletions

4
xmonad/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
xmonad-x86_64-linux
xmonad.errors
xmonad.hi
xmonad.o

141
xmonad/README.markdown Normal file
View file

@ -0,0 +1,141 @@
# xmonad-config
xmonad-config is the [xmonad](http://xmonad.org/) configuration used by Vic Fryzel.
## Introduction
If you are unfamiliar with xmonad, it is a tiling window manager that is
notoriously minimal, stable, beautiful, and featureful. If you find yourself
spending a lot of time organizing or managing windows, you may consider trying
xmonad.
However, xmonad can be somewhat difficult to configure if you're new to
Haskell or even to xmonad itself.
This project contains a completely working and very usable xmonad
configuration "out of the box". If you are just starting out with xmonad,
this will give you a configuration that I personally use for around 12 hours
every day. Thought has been put into the colors, key bindings, layouts,
and supplementary scripts to make life easier.
This project is also recommended for advanced xmonad users, who may just not
want to reinvent the wheel. All source provided with this project is well
documented and simple to customize.
![Screenshot of xmonad-config](/vicfryzel/xmonad-config/raw/master/screenshot.png)
For source code, or to contribute, see the
[xmonad-config project page](http://github.com/vicfryzel/xmonad-config).
## Requirements
* xmonad 0.9.1 or 0.9.2
* xmonad-contrib 0.9.1 or 0.9.2
* [xmobar 0.11.1 or 0.13](http://projects.haskell.org/xmobar/)
* [trayer 1.0](http://fbpanel.sourceforge.net/)
* [dmenu 4.0](http://tools.suckless.org/dmenu/)
* [yeganesh 2.2](http://dmwit.com/yeganesh/)
* [scrot 0.8](http://freshmeat.net/projects/scrot/)
### Installing requirements on [Arch Linux](http://www.archlinux.org/)
sudo pacman -S xmonad xmonad-contrib xmobar trayer dmenu scrot \
cabal-install
cabal update
cabal install yeganesh
### Installing requirements on [Ubuntu Linux](http://www.ubuntu.com/)
sudo aptitude install xmonad libghc6-xmonad-contrib-dev xmobar trayer \
suckless-tools scrot cabal-install
cabal update
cabal install yeganesh
## Installation
Installing xmonad-config is a matter of backing up any xmonad configuration
you may already have, cloning the git repository, and updating your PATH.
cd
mv .xmonad .xmonad.orig
git clone https://github.com/vicfryzel/xmonad-config.git .xmonad
echo "export PATH=\$PATH:~/.cabal/bin:~/.xmonad/bin" >> ~/.bashrc
source ~/.bashrc
Once xmonad-config is installed, you also need to ensure you can actually
start xmonad. The mechanism to do this varies based on each environment, but
here are some instructions for some common login managers.
### Starting xmonad from xdm, kdm, or gdm
echo xmonad >> ~/.xsession
# Note: this method will start no programs in your new session upon login.
# To get a terminal in your next session, press Alt+Shift+Enter.
# Logout, login from xdm/kdm/gdm
### Starting xmonad from slim
ln -s ~/.xmonad/xinitrc ~/.xinitrc
# Logout, login from slim
## Keyboard shortcuts
After starting xmonad, use the following keyboard shortcuts to function in
your new window manager. I recommend you print these out so that you don't
get stranded once you logout and back in.
* Alt+Shift+Return: Start a terminal
* Alt+Ctrl+l: Lock screen
* Alt+p: Start dmenu. Once it comes up, type the name of a program and enter
* Alt+Shift+p: Take screenshot in select mode. Click or click and drag to select
* Alt+Ctrl+Shift+p: Take fullscreen screenshot. Supports multiple monitors
* Alt+Shift+c: Close focused window
* Alt+Space: Change workspace layout
* Alt+Shift+Space: Change back to default workspace layout
* Alt+n: Resize viewed windows to the correct size
* Alt+Tab: Focus next window
* Alt+j: Focus next window
* Alt+k: Focus previous window
* Alt+m: Focus master window
* Alt+Return: Swap focused window with master window
* Alt+Shift+j: Swap focused window with next window
* Alt+Shift+k: Swap focused window with previous window
* Alt+h: Shrink master window area
* Alt+l: Expand master window area
* Alt+t: Push floating window back into tiling
* Alt+,: Increment number of windows in master window area
* Alt+.: Decrement number of windows in master window area
* Alt+q: Restart xmonad. This reloads xmonad configuration, does not logout
* Alt+Shift+q: Quit xmonad and logout
* Alt+[1-9]: Switch to workspace 1-9, depending on which number was pressed
* Alt+Shift+[1-9]: Send focused window to workspace 1-9
* Alt+w: Focus left-most monitor (Xinerama screen 1)
* Alt+e: Focus center-most monitor (Xinerama screen 2)
* Alt+r: Focus right-most monitor (Xinerama screen 3)
* Alt+Shift+w: Send focused window to workspace on left-most monitor
* Alt+Shift+e: Send focused window to workspace on center-most monitor
* Alt+Shift+r: Send focused window to workspace on right-most monitor
* Alt+Left Mouse Drag: Drag focused window out of tiling
* Alt+Right Mouse Drag: Resize focused window, bring out of tiling if needed
## Personalizing or modifying xmonad-config
Once cloned, xmonad-config is laid out as follows.
All xmonad configuration is in ~/.xmonad/xmonad.hs. This includes
things like key bindings, colors, layouts, etc. You may need to have some
basic understanding of [Haskell](http://www.haskell.org/haskellwiki/Haskell)
in order to modify this file, but most people have no problems.
Most of the xmobar configuration is in ~/.xmonad/xmobar.hs.
All scripts are in ~/.xmonad/bin/. Scripts are provided to do things like
take screenshots, start the system tray, start dmenu, or fix your multi-head
layout after a fullscreen application may have turned off one of the screens.
Colors set in the xmobar config and dmenu script are meant to coincide with the
[IR_Black terminal and vim themes](http://blog.infinitered.com/entries/show/6).

9
xmonad/bin/dmenu Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
# Script to launch dmenu with colors matching IR_Black theme
# Author: Vic Fryzel
# http://github.com/vicfryzel/xmonad-config
eval `exec /usr/bin/dmenu_run -fn '9x15' \
-nb '#000000' -nf '#FFFFFF' -sb '#333333' -sf '#CEFFAC' -p '>' -i`

7
xmonad/bin/fixscreens Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
# Fix screens after, for example, a fullscreen game shut off one monitor.
# Author: Vic Fryzel
# http://github.com/vicfryzel/xmonad-config
xrandr -s 0

7
xmonad/bin/screenshot Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
# Take screenshot of entire screen (multi-head) and display shot.
# Author: Vic Fryzel
# http://github.com/vicfryzel/xmonad-config
sleep 0.2; scrot -m "$HOME/Pictures/%Y-%m-%d-%H%M%S_\$wx\$h.png" -e "xdg-open \$f"

7
xmonad/bin/select-screenshot Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
# Allow screenshot to be selected from cursor, then display shot image.
# Author: Vic Fryzel
# http://github.com/vicfryzel/xmonad-config
sleep 0.2; scrot -s "$HOME/Pictures/%Y-%m-%d-%H%M%S_\$wx\$h.png" -e "xdg-open \$f"

11
xmonad/bin/tray Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
# Script to launch trayer in the correct position next to xmobar.
# Author: Vic Fryzel
# http://github.com/vicfryzel/xmonad-config
# This is setup to display on dual 1680x1050 monitors, with the right-side
# monitor as primary. Adjust margin as necessary for other resolutions/setups.
trayer --edge top --expand true --SetDockType true \
--align right --margin 0 --width 10 --widthtype percent --height 22 \
--padding 1 --tint 0x000000 --alpha 0 --transparent true

39
xmonad/bin/xinitrc Executable file
View file

@ -0,0 +1,39 @@
#!/bin/sh
# Script to configure X, start common apps, and start xmonad.
# Author: Vic Fryzel
# http://github.com/vicfryzel/xmonad-config
# Configure PATH so that we can access our scripts below
PATH=$PATH:~/.cabal/bin:~/.xmonad/bin
# Configure X
xsetroot -cursor_name left_ptr &
xrdb -merge ~/.Xdefaults &
# xscreensaver -no-splash &
feh --bg-scale ~/Pictures/chilewaterfall.jpg &
# Automatically mount removable media
thunar --daemon &
# Get us some decent gtk themes going
gnome-settings-daemon &
# Start network manage applet
nm-applet &
# Start the system tray
tray &
# Start two terminals
# urxvt &
# urxvt &
# Start two Chromium windows
# chromium &
# chromium &
# Start xchat (IRC client)
# xchat &
exec ck-launch-session dbus-launch --sh-syntax --exit-with-session xmonad

22
xmonad/xmobar.hs Normal file
View file

@ -0,0 +1,22 @@
-- xmobar config used by Vic Fryzel
-- Author: Vic Fryzel
-- http://github.com/vicfryzel/xmonad-config
Config {
font = "xft:Fixed-11"
bgColor = "#000000",
fgColor = "#ffffff",
position = TopW L 90,
lowerOnStart = True,
commands = [
Run Weather "KTPA" ["-t","<tempF>F <skyCondition>","-L","64","-H","77","-n","#CEFFAC","-h","#FFB6B0","-l","#96CBFE"] 36000,
Run MultiCpu ["-t","CPU <total0> <total1> <total2> <total3>","-L","30","-H","60","-h","#FFB6B0","-l","#CEFFAC","-n","#FFFFCC","-w","3"] 10,
Run Memory ["-t","MEM <usedratio>%","-H","8192","-L","4096","-h","#FFB6B0","-l","#CEFFAC","-n","#FFFFCC"] 10,
Run Swap ["-t","SWP <usedratio>%","-H","1024","-L","512","-h","#FFB6B0","-l","#CEFFAC","-n","#FFFFCC"] 10,
Run Date "%a %b %e %T" "date" 10,
Run StdinReader
],
sepChar = "%",
alignSep = "}{",
template = "%StdinReader% }{ %multicpu% <fc=#FFB6B0>:</fc> %memory% <fc=#FFB6B0>:</fc> %KTPA% <fc=#FFB6B0>:</fc> <fc=#FFFFCC>%date%</fc> "

BIN
xmonad/xmonad-i386-linux Executable file

Binary file not shown.

387
xmonad/xmonad.hs Normal file
View file

@ -0,0 +1,387 @@
-- xmonad config used by Vic Fryzel
-- Author: Vic Fryzel
-- http://github.com/vicfryzel/xmonad-config
import System.IO
import System.Exit
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.SetWMName
import XMonad.Config.Gnome
import XMonad.Layout.NoBorders
import XMonad.Layout.Spacing
import XMonad.Layout.Grid
import XMonad.Layout.Spiral
import XMonad.Layout.Tabbed
import XMonad.Layout.PerWorkspace
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import qualified XMonad.StackSet as W
import qualified Data.Map as M
------------------------------------------------------------------------
-- Terminal
-- The preferred terminal program, which is used in a binding below and by
-- certain contrib modules.
--
myTerminal = "/usr/bin/gnome-terminal"
------------------------------------------------------------------------
-- Workspaces
-- The default number of workspaces (virtual screens) and their names.
--
myWorkspaces = ["1:cli","2:www","3:mail","4:snd","5:vm"] ++ map show [6..9]
------------------------------------------------------------------------
-- Window rules
-- Execute arbitrary actions and WindowSet manipulations when managing
-- a new window. You can use this to, for example, always float a
-- particular program, or have a client always appear on a particular
-- workspace.
--
-- To find the property name associated with a program, use
-- > xprop | grep WM_CLASS
-- and click on the client you're interested in.
--
-- To match on the WM_NAME, you can use 'title' in the same way that
-- 'className' and 'resource' are used below.
--
myManageHook = composeAll
[ resource =? "chromium-browser" --> doShift "2:www"
, resource =? "desktop_window" --> doIgnore
, className =? "Firefox" --> doShift "2:www"
, className =? "Empathy" --> doShift "2:www"
, className =? "Galculator" --> doFloat
, className =? "Gimp" --> doFloat
, className =? "Google-chrome" --> doShift "2:www"
, className =? "Thunderbird" --> doShift "3:mail"
, resource =? "gpicview" --> doFloat
, resource =? "kdesktop" --> doIgnore
, className =? "MPlayer" --> doFloat
, resource =? "skype" --> doShift "6"
, resource =? "nm-connection-editor" --> doFloat
, className =? "VirtualBox" --> doShift "5:vm"
, className =? "Rhythmbox" --> doShift "4:snd"
, className =? "Banshee" --> doShift "4:snd"
, className =? "Agave" --> doFloat]
------------------------------------------------------------------------
-- Layouts
-- You can specify and transform your layouts by modifying these values.
-- If you change layout bindings be sure to use 'mod-shift-space' after
-- restarting (with 'mod-q') to reset your layout state to the new
-- defaults, as xmonad preserves your old layout settings by default.
--
-- The available layouts. Note that each layout is separated by |||,
-- which denotes layout choice.
--
nmaster = 1
ratio = 1/2
delta = 3/100
tiled = spacing 2 $ Tall nmaster delta ratio
grid = spacing 2 $ Grid
web = spacing 2 $ Tall 1 (3/100) (80/100)
full = noBorders $ Full
myLayout = avoidStruts (onWorkspace "2:www" web tiled ||| grid ||| full)
{- myLayout = avoidStruts ( -}
{- Tall 1 (3/100) (1/2) ||| -}
{- Mirror (Tall 1 (3/100) (1/2)) ||| -}
{- tabbed shrinkText tabConfig ||| -}
{- Full ||| -}
{- spiral (6/7)) -}
------------------------------------------------------------------------
-- Colors and borders
-- Currently based on the ir_black theme.
--
myNormalBorderColor = "#7c7c7c"
myFocusedBorderColor = "#ffb6b0"
-- Colors for text and backgrounds of each tab when in "Tabbed" layout.
tabConfig = defaultTheme {
activeBorderColor = "#7C7C7C",
activeTextColor = "#CEFFAC",
activeColor = "#000000",
inactiveBorderColor = "#7C7C7C",
inactiveTextColor = "#EEEEEE",
inactiveColor = "#000000"
}
-- Color of current window title in xmobar.
xmobarTitleColor = "#FFB6B0"
-- Color of current workspace in xmobar.
xmobarCurrentWorkspaceColor = "#CEFFAC"
xmobarCurrentWorkspaceBackgroundColor = "#333333"
-- Width of the window border in pixels.
myBorderWidth = 1
------------------------------------------------------------------------
-- Key bindings
--
-- modMask lets you specify which modkey you want to use. The default
-- is mod1Mask ("left alt"). You may also consider using mod3Mask
-- ("right alt"), which does not conflict with emacs keybindings. The
-- "windows key" is usually mod4Mask.
--
myModMask = mod1Mask
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
----------------------------------------------------------------------
-- Custom key bindings
--
-- Start a terminal. Terminal to start is specified by myTerminal variable.
[ ((modMask .|. shiftMask, xK_Return),
spawn $ XMonad.terminal conf)
-- Lock the screen using xscreensaver.
, ((modMask .|. controlMask, xK_l),
spawn "slock")
-- Launch dmenu via yeganesh.
-- Use this to launch programs without a key binding.
, ((modMask, xK_p),
spawn "~/.xmonad/bin/dmenu")
-- Take a screenshot in select mode.
-- After pressing this key binding, click a window, or draw a rectangle with
-- the mouse.
, ((modMask .|. shiftMask, xK_p),
spawn "~/.xmonad/bin/select-screenshot")
-- Take full screenshot in multi-head mode.
-- That is, take a screenshot of everything you see.
, ((modMask .|. controlMask .|. shiftMask, xK_p),
spawn "~/.xmonad/bin/screenshot")
-- Mute volume.
, ((0, 0x1008FF12),
spawn "amixer -q set Front toggle")
-- Decrease volume.
, ((0, 0x1008FF11),
spawn "amixer -q set Front 10%-")
-- Increase volume.
, ((0, 0x1008FF13),
spawn "amixer -q set Front 10%+")
-- Audio previous.
, ((0, 0x1008FF16),
spawn "")
-- Play/pause.
, ((0, 0x1008FF14),
spawn "")
-- Audio next.
, ((0, 0x1008FF17),
spawn "")
-- Eject CD tray.
, ((0, 0x1008FF2C),
spawn "eject -T")
--------------------------------------------------------------------
-- "Standard" xmonad key bindings
--
-- Close focused window.
, ((modMask .|. shiftMask, xK_c),
kill)
-- Cycle through the available layout algorithms.
, ((modMask, xK_space),
sendMessage NextLayout)
-- Reset the layouts on the current workspace to default.
, ((modMask .|. shiftMask, xK_space),
setLayout $ XMonad.layoutHook conf)
-- Resize viewed windows to the correct size.
, ((modMask, xK_n),
refresh)
-- Move focus to the next window.
, ((modMask, xK_Tab),
windows W.focusDown)
-- Move focus to the next window.
, ((modMask, xK_j),
windows W.focusDown)
-- Move focus to the previous window.
, ((modMask, xK_k),
windows W.focusUp )
-- Move focus to the master window.
, ((modMask, xK_m),
windows W.focusMaster )
-- Swap the focused window and the master window.
, ((modMask, xK_Return),
windows W.swapMaster)
-- Swap the focused window with the next window.
, ((modMask .|. shiftMask, xK_j),
windows W.swapDown )
-- Swap the focused window with the previous window.
, ((modMask .|. shiftMask, xK_k),
windows W.swapUp )
-- Shrink the master area.
, ((modMask, xK_h),
sendMessage Shrink)
-- Expand the master area.
, ((modMask, xK_l),
sendMessage Expand)
-- Push window back into tiling.
, ((modMask, xK_t),
withFocused $ windows . W.sink)
-- Increment the number of windows in the master area.
, ((modMask, xK_comma),
sendMessage (IncMasterN 1))
-- Decrement the number of windows in the master area.
, ((modMask, xK_period),
sendMessage (IncMasterN (-1)))
-- Toggle the status bar gap.
-- TODO: update this binding with avoidStruts, ((modMask, xK_b),
-- Quit xmonad.
, ((modMask .|. shiftMask, xK_q),
io (exitWith ExitSuccess))
-- Restart xmonad.
, ((modMask, xK_q),
restart "xmonad" True)
]
++
-- mod-[1..9], Switch to workspace N
-- mod-shift-[1..9], Move client to workspace N
[((m .|. modMask, k), windows $ f i)
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
++
-- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
-- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
[((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
------------------------------------------------------------------------
-- Mouse bindings
--
-- Focus rules
-- True if your focus should follow your mouse cursor.
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
[
-- mod-button1, Set the window to floating mode and move by dragging
((modMask, button1),
(\w -> focus w >> mouseMoveWindow w))
-- mod-button2, Raise the window to the top of the stack
, ((modMask, button2),
(\w -> focus w >> windows W.swapMaster))
-- mod-button3, Set the window to floating mode and resize by dragging
, ((modMask, button3),
(\w -> focus w >> mouseResizeWindow w))
-- you may also bind events to the mouse scroll wheel (button4 and button5)
]
------------------------------------------------------------------------
-- Status bars and logging
-- Perform an arbitrary action on each internal state change or X event.
-- See the 'DynamicLog' extension for examples.
--
-- To emulate dwm's status bar
--
-- > logHook = dynamicLogDzen
--
------------------------------------------------------------------------
-- Startup hook
-- Perform an arbitrary action each time xmonad starts or is restarted
-- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
-- per-workspace layout choices.
--
-- By default, do nothing.
myStartupHook = return ()
------------------------------------------------------------------------
-- Run xmonad with all the defaults we set up.
--
main = do
xmproc <- spawnPipe "/usr/bin/xmobar ~/.xmonad/xmobar.hs"
xmonad $ defaults {
logHook = dynamicLogWithPP $ xmobarPP {
ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor xmobarTitleColor "" . shorten 100
, ppCurrent = xmobarColor xmobarCurrentWorkspaceColor xmobarCurrentWorkspaceBackgroundColor
, ppSep = " "}
, manageHook = manageDocks <+> myManageHook
, startupHook = setWMName "LG3D"
}
------------------------------------------------------------------------
-- Combine it all together
-- A structure containing your configuration settings, overriding
-- fields in the default config. Any you don't override, will
-- use the defaults defined in xmonad/XMonad/Config.hs
--
-- No need to modify this.
--
defaults = defaultConfig {
-- simple stuff
terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse,
borderWidth = myBorderWidth,
modMask = myModMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- key bindings
keys = myKeys,
mouseBindings = myMouseBindings,
-- hooks, layouts
layoutHook = smartBorders $ myLayout,
manageHook = myManageHook,
startupHook = myStartupHook
}

53
xsessionrc Executable file
View file

@ -0,0 +1,53 @@
#!/bin/sh
# Script to configure X, start common apps, and start xmonad.
# Author: Vic Fryzel
# http://github.com/vicfryzel/xmonad-config
# Configure PATH so that we can access our scripts below
PATH=$PATH:~/.cabal/bin:~/.xmonad/bin
# Configure X
xsetroot -cursor_name left_ptr &
xrdb -merge ~/.Xdefaults &
# xscreensaver -no-splash &
#feh --bg-scale ~/Pictures/Wallpaper/wing.jpg &
# Automatically mount removable media
#thunar --daemon &
# Start the system tray
tray &
# Start network manage applet
#nm-applet &
# start skype for work purposes
#skype &
# Start a terminal
gnome-terminal &
# Start some muther flippin chat client
#empathy &
# Start browsers
chromium-browser &
#firefox &
shutter --min_at_startup &
tomboy &
naturalscrolling &
#dropbox start -i
# Start xchat (IRC client)
# xchat &
gnome-session &
# Required for battery status and other things.
gnome-settings-daemon &
# Clears out the wallpaper (fixes issue with login screen background persisting)
gsettings set org.gnome.desktop.background picture-uri ""
exec ssh-agent dbus-launch --sh-syntax --exit-with-session xmonad