From 342caa641bc6c530d65e84891a562a521e0ce091 Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Fri, 23 Sep 2022 00:46:34 +0200 Subject: [PATCH] Add xmonad configuration --- .xmobarrc | 97 +++++++++++++++++++++++++++++++++++++++++++++++ .xmonad/xmonad.hs | 85 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 .xmobarrc create mode 100644 .xmonad/xmonad.hs diff --git a/.xmobarrc b/.xmobarrc new file mode 100644 index 0000000..b8ed420 --- /dev/null +++ b/.xmobarrc @@ -0,0 +1,97 @@ +Config { + -- appearance + font = "xft:Iosevka Term SS08:size=12:antialias=true" + , bgColor = "#111" + , fgColor = "#ccc" + , position = Top + , border = BottomB + , borderColor = "#333" + + -- layout + , sepChar = "%" -- delineator between plugin names and straight text + , alignSep = "}{" -- separator between left-right alignment + , template = "%battery% | %multicpu% | %coretemp% | %memory% | %dynnetwork% }{ %RJTT% | %date%" + + -- general behavior + , lowerOnStart = True -- send to bottom of window stack on start + , hideOnStart = False -- start with window unmapped (hidden) + , allDesktops = True -- show on all desktops + , overrideRedirect = True -- set the Override Redirect flag (Xlib) + , pickBroadest = False -- choose widest display (multi-monitor) + , persistent = True -- enable/disable hiding (True = disabled) + + -- plugins + -- Numbers can be automatically colored according to their value. xmobar + -- decides color based on a three-tier/two-cutoff system, controlled by + -- command options: + -- --Low sets the low cutoff + -- --High sets the high cutoff + -- + -- --low sets the color below --Low cutoff + -- --normal sets the color between --Low and --High cutoffs + -- --High sets the color above --High cutoff + -- + -- The --template option controls how the plugin is displayed. Text + -- color can be set by enclosing in tags. For more details + -- see http://projects.haskell.org/xmobar/#system-monitor-plugins. + , commands = + + -- weather monitor + [ Run Weather "RJTT" [ "--template", " | °C | % | hPa" + ] 36000 + + -- network activity monitor (dynamic interface resolution) + , Run DynNetwork [ "--template" , ": kB/s|kB/s" + , "--Low" , "1000" -- units: B/s + , "--High" , "5000" -- units: B/s + , "--low" , "green" + , "--normal" , "orange" + , "--high" , "red" + ] 10 + + -- cpu activity monitor + , Run MultiCpu [ "--template" , "Cpu: %|%" + , "--Low" , "50" -- units: % + , "--High" , "85" -- units: % + , "--low" , "green" + , "--normal" , "orange" + , "--high" , "red" + ] 10 + + -- cpu core temperature monitor + , Run CoreTemp [ "--template" , "Temp: °C|°C" + , "--Low" , "70" -- units: °C + , "--High" , "80" -- units: °C + , "--low" , "green" + , "--normal" , "orange" + , "--high" , "red" + ] 50 + + -- memory usage monitor + , Run Memory [ "--template" ,"Mem: %" + , "--Low" , "20" -- units: % + , "--High" , "90" -- units: % + , "--low" , "green" + , "--normal" , "orange" + , "--high" , "red" + ] 10 + + -- battery monitor + , Run Battery [ "--template" , "Bat " + , "--Low" , "30" -- units: % + , "--High" , "80" -- units: % + , "--low" , "red" + , "--normal" , "orange" + , "--high" , "gray" + + , "--" -- battery specific options + -- discharging status + , "-o" , "% ()" + -- AC "on" status + , "-O" , "Charging" + -- charged status + , "-i" , "Charged" + ] 50 + , Run Date "%a %d/%m W%w %H:%M" "date" 10 + ] + } diff --git a/.xmonad/xmonad.hs b/.xmonad/xmonad.hs new file mode 100644 index 0000000..0b5549b --- /dev/null +++ b/.xmonad/xmonad.hs @@ -0,0 +1,85 @@ +import System.IO +import XMonad +import XMonad.Config.Desktop +import XMonad.Hooks.DynamicLog +import XMonad.Hooks.ManageDocks +import XMonad.Layout.BorderResize +import XMonad.Layout.Fullscreen +import XMonad.Layout.Grid +import XMonad.Layout.NoBorders (noBorders, smartBorders) +import XMonad.Layout.ResizableTile (MirrorResize (..), + ResizableTall (..)) +import XMonad.Layout.Spacing +import XMonad.Layout.Tabbed (Theme (..), shrinkText, + tabbedAlways) +import XMonad.Layout.ToggleLayouts (ToggleLayout (..), toggleLayouts) +import XMonad.Layout.WindowArranger +import XMonad.Util.EZConfig +import XMonad.Util.Paste +import XMonad.Util.Run (spawnPipe) + +import XMonad.Actions.CycleWS +import XMonad.Actions.GridSelect +import XMonad.Actions.WindowGo +import XMonad.Hooks.EwmhDesktops +import XMonad.Hooks.ManageHelpers +import XMonad.Hooks.ScreenCorners + +import qualified Data.Map.Strict as M +import qualified XMonad.StackSet as W + +myStartupHook = do + addScreenCorners [ (SCLowerRight, nextWS) + , (SCLowerRight, prevWS) + ] + +main = do + xmproc <- spawnPipe "xmobar" + xmonad $ def { + terminal = "alacritty" + -- Use Win key instead of Alt + , modMask = mod4Mask + , workspaces = ["α", "β", "γ", "δ", "ε"] + -- Styling + , focusedBorderColor = "#000000" + , normalBorderColor = "#111111" + , borderWidth = 2 + -- Hooks + , startupHook = myStartupHook + , layoutHook = screenCornerLayoutHook $ layoutHook def + , handleEventHook = handleEventHook def <+> screenCornerEventHook + , logHook = dynamicLogWithPP xmobarPP + { ppOutput = hPutStrLn xmproc + , ppTitle = xmobarColor "green" "" . shorten 50 + } + } `additionalKeysP` + -- Keybindings to be added + [ ("M-S-", withFocused $ windows . W.sink) + , ("M-p", spawn "rofi -show run") + -- Map insert key to paste from clipboard + , ("", pasteSelection) + -- Map print screen to take a screenshot with flameshot + , ("", spawn "flameshot gui") + -- Map audio keys to control volume + , ("", spawn "pactl set-sink-volume @DEFAULT_SINK@ +5%") + , ("", spawn "pactl set-sink-volume @DEFAULT_SINK@ -5%") + , ("", spawn "pactl set-sink-mute @DEFAULT_SINK@ toggle") + -- Map brightness keys to control brightness with brightnessctl + , ("", spawn "brightnessctl set 20+") + , ("", spawn "brightnessctl set 20-") + -- Map brightness keys + shift to adjust redshift temperature + , ("S-", spawn "echo $(($(cat /tmp/temperature) + 50)) > /tmp/temperature && redshift -O $(cat /tmp/temperature) -P && notify < /tmp/temperature -h string:x-canonical-private-synchronous:anything") + , ("S-", spawn "echo $(($(cat /tmp/temperature) - 50)) > /tmp/temperature && redshift -O $(cat /tmp/temperature) -P && notify < /tmp/temperature -h string:x-canonical-private-synchronous:anything") + -- Reset redshift temperature + , ("M-S-", spawn "echo 3000 > /tmp/temperature && redshift -x") + , ("M-S-", spawn "echo 3000 > /tmp/temperature && redshift -x") + -- Use power down key to suspend + , ("", spawn "systemctl suspend") + , ("M-q", spawn "xmonad --recompile; pkill xmobar; xmonad --restart") + ] + `removeKeysP` + -- Keybindings to be removed + [ "M-t" ] + +mainManageHook = composeAll + [ className =? "plank" --> doIgnore ]