Bläddra i källkod

Cleanup code, add todos

Josh Bicking 6 år sedan
förälder
incheckning
8fe16b9875
2 ändrade filer med 22 tillägg och 151 borttagningar
  1. 3 58
      xmonad/.xmobarrc
  2. 19 93
      xmonad/.xmonad/xmonad.hs

+ 3 - 58
xmonad/.xmobarrc

@@ -35,62 +35,7 @@ Config {
    --   The --template option controls how the plugin is displayed. Text
    --   color can be set by enclosing in <fc></fc> tags. For more details
    --   see http://projects.haskell.org/xmobar/#system-monitor-plugins.
-   , commands =
-
-        -- weather monitor
-        [ Run Weather "RJTT" [ "--template", "<fc=#4682B4><tempF></fc>°F"
-                             ] 36000
-
-        -- network activity monitor (dynamic interface resolution)
-        , Run DynNetwork     [ "--template" , "<dev>: ⬇️<rx>kB/s, ⬆️<tx>kB/s"
-                             , "--Low"      , "1000"       -- units: B/s
-                             , "--High"     , "5000"       -- units: B/s
-                             , "--low"      , "green"
-                             , "--normal"   , "darkorange"
-                             , "--high"     , "red"
-                             ] 10
-
-        -- cpu activity monitor
-	, Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
-
-        , Run MultiCpu       [ "--template" , "Cpu: <total0>%|<total1>%"
-                             , "--Low"      , "50"         -- units: %
-                             , "--High"     , "85"         -- units: %
-                             , "--low"      , "green"
-                             , "--normal"   , "orange"
-                             , "--high"     , "red"
-                             ] 10
-
-        -- memory usage monitor
-        , Run Memory         [ "--template" ,"Mem: <usedratio>%"
-                             , "--Low"      , "20"        -- units: %
-                             , "--High"     , "90"        -- units: %
-                             , "--low"      , "green"
-                             , "--normal"   , "orange"
-                             , "--high"     , "red"
-                             ] 10
-
-        -- battery monitor
-        , Run Battery        [ "--template" , "<acstatus>"
-                             , "--Low"      , "10"        -- units: %
-                             , "--High"     , "80"        -- units: %
-                             , "--low"      , "red"
-                             , "--normal"   , "orange"
-                             , "--high"     , "green"
-
-                             , "--" -- battery specific options
-                                       -- discharging status
-                                       , "-o"	, "⚇ <left>% (<timeleft>)"
-                                       -- AC "on" status
-                                       , "-O"	, "⚡ <left>% (<timeleft>)"
-                                       -- charged status
-                                       , "-i"	, "<left>%"
-                             ] 50
-
-        -- time and date indicator
-        --   (%F = y-m-d date, %a = day of week, %T = h:m:s time)
-        , Run Date           "<fc=#ABABAB>%F (%a) %T</fc>" "date" 10
-
-	, Run StdinReader
-    ]
+   , commands = [
+       Run StdinReader
+     ]
 }

+ 19 - 93
xmonad/.xmonad/xmonad.hs

@@ -1,46 +1,35 @@
-import System.Posix.Env (getEnv)
-import Data.Maybe (maybe)
-import Control.Monad(when, liftM)
-
 import XMonad
-import XMonad.Config.Desktop
-import XMonad.Hooks.DynamicLog
-import XMonad.Hooks.ManageDocks
+import XMonad.Hooks.DynamicLog(dynamicLogWithPP
+                              , xmobarPP
+                              , ppOutput
+                              , ppLayout
+                              , ppTitle)
+import XMonad.Hooks.ManageDocks(docks, docksEventHook, manageDocks, avoidStruts)
 import XMonad.Util.Run(spawnPipe, hPutStrLn, runProcessWithInput)
 
 -- Layouts
 import XMonad.Layout.Spacing(smartSpacing)
-import XMonad.Layout.Tabbed
-import XMonad.Layout.NoBorders
-import XMonad.Layout.IndependentScreens
+import XMonad.Layout.Tabbed(simpleTabbed)
+import XMonad.Layout.NoBorders(withBorder, smartBorders)
+import XMonad.Layout.IndependentScreens(countScreens)
 
 -- Shutdown commands and keys
 import Data.Map(fromList)
-import XMonad.Prompt
-import XMonad.Prompt.XMonad
-import XMonad.Prompt.ConfirmPrompt
-import System.Exit(ExitCode(ExitSuccess), exitWith)
-import XMonad.Util.EZConfig(additionalKeys, removeKeys)
-import XMonad.Util.Dmenu
-
--- Brightness and audio keys
-import Graphics.X11.ExtraTypes.XF86
+import XMonad.Util.EZConfig(removeKeys)
 
+-- For starting up a list of programs
 import Data.List(elemIndex, foldl1')
+
 import qualified XMonad.StackSet as W
 import qualified Data.Map as M
 
--- kde
-import XMonad.Config.Kde
+import XMonad.Config.Kde(kde4Config, desktopLayoutModifiers)
 
-import XMonad.Hooks.EwmhDesktops
+import XMonad.Hooks.EwmhDesktops(ewmh, fullscreenEventHook)
 
 myModMask = mod4Mask
 myTerminal   = "konsole"
 
--- Command to launch the bar.
-myBar = "xmobar"
-
 -- Custom PP, configure it as you like. It determines what is being written to the bar.
 myPP = xmobarPP { ppTitle = \_ -> ""
                 , ppLayout = \_ -> ""}
@@ -68,76 +57,11 @@ main = do
   , startupHook = startup startupList
   , handleEventHook = handleEventHook kde4Config <+> fullscreenEventHook <+> docksEventHook
   , modMask     = mod4Mask
-  , keys        = \c -> mySetKeys c `M.union` keys kde4Config c
-  } --`additionalKeys` (if session == "xmonad" then (myKeys ++ xmonadKeys) else myKeys)
+  , keys        = \c -> myKeys c `M.union` keys kde4Config c
+  }
     `removeKeys` myRemoveKeys
 
-xmonadStartupList =
-  [ "feh --bg-scale ~/Owncloud/Backgrounds/Xmbindings.png"
-  -- , "trayer --edge top --align right --SetDockType true --SetPartialStrut true --expand true --width 10 --transparent true --alpha 0 --tint 0x000000 --height 22"
-  , "pasystray"
-  , "xfce4-clipman"
-  , "xbacklight -set 12"
-  , "compton"
-  , "xscreensaver -nosplash"
-  ]
-
-mySetKeys conf@(XConfig {XMonad.modMask = myModMask}) =
-    -- M.fromList $ myKeys ++ xmonadKeys
-    M.fromList $ myKeys
-  where
---    xmonadKeys = [
---  -- scrot
---        ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
---      , ((0, xK_Print), spawn "scrot")
---
---      -- rofi
---      , ((myModMask, xK_p ), spawn "rofi -show run")
---      -- shutdown
---      --, ((myModMask .|. shiftMask, xK_q),
---      --   xmonadPrompt defaultXPConfig
---      --   { promptKeymap = fromList
---      --     [ ((0, xK_r), do
---      --           spawn "emacsclient -e '(kill emacs)'"
---      --           spawn "systemctl reboot")
---      --     , ((0 , xK_s), do
---      --           spawn "emacsclient -e '(kill emacs)'"
---      --           spawn "sudo poweroff")
---      --     , ((0, xK_e), do
---      --           spawn "emacsclient -e '(kill emacs)'"
---      --           io $ exitWith ExitSuccess)
---      --     , ((0, xK_l),  do
---      --           spawn "xscreensaver-command -lock"
---      --           quit)
---      --     , ((0, xK_z), do
---      --           spawn "xscreensaver-command -lock"
---      --           spawn "systemctl suspend"
---      --           quit)
---      --     , ((0, xK_Escape), quit)
---      --     ]
---      --   , defaultText = "(r) Reboot, (s) Shutdown, (e) Exit, (l) Lock, (z) Sleep"
---      --   })
---      -- pulseaudio
---      , ((0, xF86XK_AudioRaiseVolume),
---             spawn "pactl set-sink-volume alsa_output.pci-0000_00_1f.3.analog-stereo +5%")
---      , ((0, xF86XK_AudioLowerVolume),
---             spawn "pactl set-sink-volume alsa_output.pci-0000_00_1f.3.analog-stereo -5%")
---      , ((0, xF86XK_AudioMute),
---             spawn "pactl set-sink-mute alsa_output.pci-0000_00_1f.3.analog-stereo toggle")
---
---      -- brightness
---      , ((0, xF86XK_MonBrightnessUp),
---         let
---            returnValM = fmap init $ runProcessWithInput "xbacklight" [] ""
---         in do
---           currentBrightness <- returnValM
---           if (read currentBrightness :: Double) == 0 then
---             spawn "xbacklight -set 2"
---           else
---             spawn "xbacklight -inc 5")
---      , ((0, xF86XK_MonBrightnessDown), spawn "xbacklight -dec 5")
---      ]
-    myKeys =
+myKeys conf@(XConfig {XMonad.modMask = myModMask}) = M.fromList $
       [
       -- extra programs
       ((myModMask, xK_x),
@@ -274,6 +198,7 @@ startupList :: [String]
 startupList =
   [ "compton"
   , "nextcloud"
+  -- TODO find a way around this dirty hack
   , "sleep 5 && for i in `xdotool search --all --name xmobar`; do xdotool windowraise $i; done"
   ]
 
@@ -282,6 +207,7 @@ startup l = do
   foldl1' (>>) $ map (spawn . ifNotRunning) l
 
 -- Wrap a command in Bash that checks if it's running.
+-- TODO do this in haskell
 ifNotRunning :: String -> String
 ifNotRunning s = "if [ `pgrep -c " ++ (basename s) ++ "` == 0 ]; then " ++ s ++ "; fi"