Created
September 21, 2018 12:29
-
-
Save enko/f884a44006ce13010b4ec5077d21657f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# OPTIONS_GHC -W -fwarn-unused-imports #-} | |
import Control.Monad | |
import Data.Bits ((.|.)) | |
import Data.Ratio | |
import Graphics.X11.Xlib | |
import System.Exit | |
import System.IO | |
import System.IO (hPutStrLn) | |
import XMonad | |
import XMonad.Actions.CycleWS | |
import XMonad.Actions.DwmPromote | |
import XMonad.Actions.DynamicWorkspaces | |
import XMonad.Actions.FindEmptyWorkspace | |
import XMonad.Actions.Submap | |
import XMonad.Actions.UpdatePointer | |
import XMonad.Actions.Warp | |
import XMonad.Config.Desktop | |
import XMonad.Config.Kde | |
import XMonad.Core | |
import XMonad.Hooks.DynamicLog hiding (shorten) | |
import XMonad.Hooks.EwmhDesktops | |
import XMonad.Hooks.ManageDocks | |
import XMonad.Hooks.ManageHelpers | |
import XMonad.Hooks.UrgencyHook | |
import XMonad.Layout | |
import XMonad.Layout.Circle | |
import XMonad.Layout.Grid | |
import XMonad.Layout.LayoutHints | |
import XMonad.Layout.Magnifier | |
import XMonad.Layout.NoBorders (noBorders) | |
import XMonad.Layout.PerWorkspace | |
import XMonad.Layout.ResizableTile | |
import XMonad.Layout.Spiral | |
import XMonad.Layout.TabBarDecoration | |
import XMonad.Layout.Tabbed | |
import XMonad.Layout.ThreeColumns | |
import XMonad.ManageHook | |
import XMonad.Operations | |
import XMonad.Prompt | |
import XMonad.Prompt.Shell | |
import XMonad.Prompt.Window | |
import XMonad.Prompt.Workspace | |
import XMonad.Prompt.XMonad | |
import XMonad.Util.EZConfig | |
import XMonad.Util.Run (spawnPipe) | |
import XMonad.Util.WorkspaceCompare | |
import qualified Data.Map as M | |
import qualified XMonad.StackSet as W | |
shorten :: Int -> String -> String | |
shorten n xs | length xs < n = xs | |
| otherwise = (take (n - length end) xs) ++ end | |
where | |
end = "..." | |
mykeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ()) | |
mykeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $ | |
-- launching and killing programs | |
[ | |
((mod4Mask .|. shiftMask, xK_Return ), withWindowSet $ \ws->when ((W.tag . W.workspace . W.current) ws=="term") (spawn "exec urxvt")) | |
-- move focus up or down the window stack | |
, ((modMask, xK_Tab ), windows W.focusDown) -- %! Move focus to the next window | |
, ((modMask .|. shiftMask, xK_Tab ), windows W.focusUp) | |
, ((mod4Mask, xK_l ), spawn "/home/tim/.local/bin/getseltrans.sh") | |
, ((mod4Mask, xK_c ), spawn "xbacklight -time 100 + 5") | |
, ((mod4Mask, xK_e ), spawn "xbacklight -time 100 - 5") | |
, ((mod4Mask, xK_i), submap . M.fromList $ | |
[ | |
((mod4Mask , xK_f), viewEmptyWorkspace) | |
, ((mod4Mask , xK_a), addWorkspace "new ws") | |
, ((mod4Mask , xK_d), removeWorkspace) | |
, ((mod4Mask , xK_m), renameWorkspace defaultXPConfig) | |
, ((mod4Mask , xK_x), shellPrompt defaultXPConfig) | |
, ((mod4Mask .|. shiftMask, xK_x), xmonadPrompt defaultXPConfig) | |
, ((mod4Mask .|. shiftMask, xK_v), windowPromptBring defaultXPConfig) | |
, ((mod4Mask , xK_v), windowPromptGoto defaultXPConfig) | |
, ((mod4Mask , xK_u), workspacePrompt defaultXPConfig (windows . W.greedyView)) | |
, ((mod4Mask , xK_comma ), sendMessage (IncMasterN 1)) -- %! Increment the number of windows in the master area | |
, ((mod4Mask , xK_period), sendMessage (IncMasterN (-1))) -- %! Deincrement the number of windows in the master area | |
, ((mod4Mask , xK_t ), withFocused $ windows . W.sink) -- %! Push window back into tiling | |
, ((mod4Mask , xK_h ), sendMessage Shrink) -- %! Shrink the master area | |
, ((mod4Mask , xK_l ), sendMessage Expand) -- %! Expand the master area | |
, ((mod4Mask , xK_Return), windows W.swapMaster) -- %! Swap the focused window and the master window | |
, ((mod4Mask .|. shiftMask, xK_j ), windows W.swapDown ) -- %! Swap the focused window with the next window | |
, ((mod4Mask .|. shiftMask, xK_k ), windows W.swapUp ) -- %! Swap the focused window with the previous window | |
-- , ((mod4Mask , xK_m ), windows W.focusMaster ) -- %! Move focus to the master window | |
, ((mod4Mask , xK_space ), sendMessage NextLayout) -- %! Rotate through the available layout algorithms | |
, ((mod4Mask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) -- %! Reset the layouts on the current workspace to default | |
, ((mod4Mask .|. shiftMask, xK_c ), kill) -- %! Close the focused window | |
, ((mod4Mask , xK_q ), broadcastMessage ReleaseResources >> restart "xmonad" True) -- %! Restart xmonad | |
] | |
++ | |
[((m .|. mod4Mask, key), screenWorkspace sc >>= flip whenJust (windows . f)) | |
| (key, sc) <- zip [xK_2, xK_1, xK_3] [0..] | |
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] | |
) | |
-- quit, or restart | |
] | |
isNotification :: Query Bool | |
isNotification = isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_NOTIFICATION" | |
isOverride :: Query Bool | |
isOverride = isInProperty "_NET_WM_WINDOW_TYPE" "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE" | |
isPlasmaNotify :: Query Bool | |
isPlasmaNotify = isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DESKTOP" | |
--isOverride = isInProperty "_NET_WM_WINDOW_TYPE" "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE, _NET_WM_WINDOW_TYPE_NORMAL" | |
-- myManageHook = composeAll | |
-- [ className =? "Amarokapp" --> doF (W.shift "music") | |
-- , className =? "Emacs" --> doF (W.shift "emacs") | |
-- , className =? "Opera" --> doF (W.shift "web") | |
-- , className =? "Kopete" --> doF (W.shift "kopete") | |
-- , className =? "Pidgin" --> doF (W.shift "comm") | |
-- , className =? "Gajim.py" --> doF (W.shift "comm") | |
-- , className =? "MPlayer" --> doFloat | |
-- ] <+> manageDocks | |
myManageHook = composeOne | |
[ className =? "Emacs" -?> doShift "emacs" | |
, className =? "Firefox" -?> doShift "web" | |
, className =? "pwsafe" -?> doShift "kx" | |
, className =? "Spotify" -?> doShift "music" | |
, className =? "code" -?> doShift "code" | |
, className =? "plasmashell" -?> doCenterFloat | |
, isDialog -?> doCenterFloat | |
, isKDETrayWindow -?> doFloat | |
, isNotification -?> doFloat | |
, isOverride -?> doFloat | |
, isPlasmaNotify -?> doFloat | |
-- Move transient windows to their parent: | |
, transience | |
] | |
mylayout = avoidStruts (tiled ||| Full) | |
where | |
-- default tiling algorithm partitions the screen into two panes | |
tiled = Tall nmaster delta ratio | |
-- The default number of windows in the master pane | |
nmaster = 1 | |
-- Default proportion of screen occupied by master pane | |
ratio = 2/3 | |
-- Percent of screen to increment by when resizing panes | |
delta = 3/100 | |
main = do | |
xmonad $ withUrgencyHook NoUrgencyHook | |
$ desktopConfig | |
{ borderWidth = 0 | |
, terminal = "termite" | |
, keys = mykeys | |
, workspaces = ["web", "code", "emacs", "term", "music", "kx" ] | |
, logHook = logHook desktopConfig | |
, layoutHook = mylayout | |
, manageHook = myManageHook <+> manageHook desktopConfig | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment