added backlight script which can be updated to support more devices, also updated xmonad.hs to use 10% increments rather than 5%

This commit is contained in:
Solomon Laing 2021-04-25 19:06:02 +09:30
parent 58f9ef2077
commit 4354d2cdc7

View File

@ -23,9 +23,8 @@ import qualified XMonad.Actions.Search as S
-- Data -- Data
import Data.Char (isSpace, toUpper) import Data.Char (isSpace, toUpper)
import Data.Maybe (fromJust) import Data.Maybe ( fromJust, isJust )
import Data.Monoid import Data.Monoid
import Data.Maybe (isJust)
import Data.Tree import Data.Tree
import qualified Data.Map as M import qualified Data.Map as M
@ -85,7 +84,7 @@ import XMonad.Util.SpawnOnce
-- The preferred terminal program, which is used in a binding below and by -- The preferred terminal program, which is used in a binding below and by
-- certain contrib modules. -- certain contrib modules.
myTerminal :: String myTerminal :: String
myTerminal = "alacritty" myTerminal = "LIBGL_ALWAYS_SOFTWARE=1 alacritty"
myFileManager :: String myFileManager :: String
myFileManager = "thunar" myFileManager = "thunar"
@ -140,7 +139,7 @@ myWorkspaces :: [String]
-- myWorkspaces = [" 1 ", " 2 ", " 3 ", " 4 ", " 5 ", " 6 ", " 7 ", " 8 ", " 9 "] -- myWorkspaces = [" 1 ", " 2 ", " 3 ", " 4 ", " 5 ", " 6 ", " 7 ", " 8 ", " 9 "]
myWorkspaces = ["web", "game", "dev", "doc", "mus", "vid", "sys", "chat", "virt"] myWorkspaces = ["web", "game", "dev", "doc", "mus", "vid", "sys", "chat", "virt"]
myWorkspaceIndices = M.fromList $ zipWith (,) myWorkspaces [1..] -- (,) == \x y -> (x,y) myWorkspaceIndices = M.fromList $ zip myWorkspaces [1..] -- (,) == \x y -> (x,y)
clickable ws = "<action=xdotool key super+"++show i++">"++ws++"</action>" clickable ws = "<action=xdotool key super+"++show i++">"++ws++"</action>"
where i = fromJust $ M.lookup ws myWorkspaceIndices where i = fromJust $ M.lookup ws myWorkspaceIndices
@ -148,9 +147,9 @@ clickable ws = "<action=xdotool key super+"++show i++">"++ws++"</action>"
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Key bindings. Add, modify or remove key bindings here. -- Key bindings. Add, modify or remove key bindings here.
-- These are general keybindings custom script bindings are not included. -- These are general keybindings custom script bindings are not included.
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ myKeys conf@XConfig {XMonad.modMask = modm} = M.fromList $
[ [
-- launch a terminal -- launch a terminal
((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
@ -224,7 +223,7 @@ myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
, ((modm, xK_b ), sendMessage ToggleStruts) , ((modm, xK_b ), sendMessage ToggleStruts)
-- Quit xmonad -- Quit xmonad
, ((modm .|. shiftMask, xK_apostrophe ), io (exitWith ExitSuccess)) , ((modm .|. shiftMask, xK_apostrophe ), io (exitSuccess))
-- Restart xmonad -- Restart xmonad
, ((modm, xK_apostrophe ), spawn "xmonad --recompile; xmonad --restart") , ((modm, xK_apostrophe ), spawn "xmonad --recompile; xmonad --restart")
@ -237,7 +236,7 @@ myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
-- --
-- these are my general custom bindings and scripts -- these are my general custom bindings and scripts
-- --
[ [
-- prompt computer shutdown -- prompt computer shutdown
((modm .|. shiftMask, xK_s ), spawn "/home/solomon/.local/bin/prompt \"Are you sure you want to Shutdown?\" \"shutdown now\"") ((modm .|. shiftMask, xK_s ), spawn "/home/solomon/.local/bin/prompt \"Are you sure you want to Shutdown?\" \"shutdown now\"")
@ -247,10 +246,10 @@ myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
-- prompt computer lock -- prompt computer lock
, ((modm, xK_Escape), spawn "/home/solomon/.local/bin/prompt \"Are you sure you want to lock?\" \"slock\" 1") , ((modm, xK_Escape), spawn "/home/solomon/.local/bin/prompt \"Are you sure you want to lock?\" \"slock\" 1")
-- unlock bitwarden cli and store session key -- unlock bitwarden cli and store session key
, ((modm .|. shiftMask, xK_t ), spawn "/home/solomon/.local/bin/bw-unlock") , ((modm .|. shiftMask, xK_t ), spawn "/home/solomon/.local/bin/bw-unlock")
-- search for password using bitwarden cli through dmenu -- search for password using bitwarden cli through dmenu
, ((modm, xK_t ), spawn "/home/solomon/.local/bin/passwords") , ((modm, xK_t ), spawn "/home/solomon/.local/bin/passwords")
@ -281,21 +280,21 @@ myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
[ [
-- decrease volume with mod+f11 -- decrease volume with mod+f11
((modm, xK_F11), spawn "/home/solomon/.local/bin/dec-sink-volume") ((modm, xK_F11), spawn "/home/solomon/.local/bin/dec-sink-volume")
-- increase volume with mod+f12 -- increase volume with mod+f12
, ((modm, xK_F12), spawn "/home/solomon/.local/bin/inc-sink-volume") , ((modm, xK_F12), spawn "/home/solomon/.local/bin/inc-sink-volume")
-- toggle mute with mod+f10 -- toggle mute with mod+f10
, ((modm, xK_F10), spawn "/home/solomon/.local/bin/toggle-sink-mute") , ((modm, xK_F10), spawn "/home/solomon/.local/bin/toggle-sink-mute")
-- decrease volume with mod+f11 -- decrease volume with mod+f11
, ((modm .|. shiftMask, xK_F11), spawn "/home/solomon/.local/bin/dec-source-volume") , ((modm .|. shiftMask, xK_F11), spawn "/home/solomon/.local/bin/dec-source-volume")
-- increase volume with mod+f12 -- increase volume with mod+f12
, ((modm .|. shiftMask, xK_F12), spawn "/home/solomon/.local/bin/inc-source-volume") , ((modm .|. shiftMask, xK_F12), spawn "/home/solomon/.local/bin/inc-source-volume")
-- toggle mute with mod+f10 -- toggle mute with mod+f10
, ((modm .|. shiftMask, xK_F10), spawn "/home/solomon/.local/bin/toggle-source-mute") , ((modm .|. shiftMask, xK_F10), spawn "/home/solomon/.local/bin/toggle-source-mute")
-- set default sink for pactl to allow above scripts to run -- set default sink for pactl to allow above scripts to run
, ((modm, xK_F7), spawn "/home/solomon/.local/bin/set-default-sink") , ((modm, xK_F7), spawn "/home/solomon/.local/bin/set-default-sink")
@ -310,10 +309,10 @@ myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
-- --
[ [
-- increase backlight by 10 with mod+f9 -- increase backlight by 10 with mod+f9
((modm, xK_F9), spawn "backlight_control +5") ((modm, xK_F9), spawn "/home/solomon/.local/bin/mod_backlight +10")
-- decrese backlight by 10 with mod+f8x -- decrese backlight by 10 with mod+f8x
, ((modm, xK_F8), spawn "backlight_control -5") , ((modm, xK_F8), spawn "/home/solomon/.local/bin/mod_backlight -10")
] ]
++ ++
@ -336,7 +335,7 @@ myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
-- Mouse bindings: default actions bound to mouse events -- Mouse bindings: default actions bound to mouse events
myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $ myMouseBindings XConfig {XMonad.modMask = modm} = M.fromList
-- mod-button1, Set the window to floating mode and move by dragging -- mod-button1, Set the window to floating mode and move by dragging
[ ((modm, button1), (\w -> focus w >> mouseMoveWindow w [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
@ -428,8 +427,9 @@ myLayout = avoidStruts $ mouseResize $ windowArrange $ T.toggleLayouts floats
spirals spirals
||| grid ||| grid
||| noBorders monocle ||| noBorders monocle
-- ||| tall
||| noBorders tabs ||| noBorders tabs
-- unused layouts
-- ||| tall
-- ||| floats -- ||| floats
-- ||| magnify -- ||| magnify
-- ||| threeCol -- ||| threeCol
@ -458,7 +458,7 @@ myManageHook = composeAll
, className =? "net-runelite-launcher-Launcher" --> doIgnore , className =? "net-runelite-launcher-Launcher" --> doIgnore
, resource =? "desktop_window" --> doIgnore , resource =? "desktop_window" --> doIgnore
, (className =? "firefox" <&&> resource =? "Dialog")--> doFloat -- Float Firefox Dialog , (className =? "firefox" <&&> resource =? "Dialog")--> doFloat -- Float Firefox Dialog
, resource =? "kdesktop" --> doIgnore , resource =? "kdesktop" --> doIgnore
, className =? "MusicBrainz Picard" --> doIgnore , className =? "MusicBrainz Picard" --> doIgnore
, className =? "Steam" --> doShift ( myWorkspaces !! (7-1) ) , className =? "Steam" --> doShift ( myWorkspaces !! (7-1) )
, className =? "discord" --> doShift ( myWorkspaces !! (8-1) ) , className =? "discord" --> doShift ( myWorkspaces !! (8-1) )
@ -496,16 +496,16 @@ myStartupHook = do
spawnOnce "blueman-applet &" spawnOnce "blueman-applet &"
spawnOnce "kdeconnect-indicator &" spawnOnce "kdeconnect-indicator &"
spawnOnce "dunst &" -- notification daemon spawnOnce "dunst &" -- notification daemon
-- Startup Applications -- Startup Applications
spawnOnce "guake &" -- spawnOnce "guake &"
spawnOnce "barrier &" spawnOnce "barrier &"
spawnOnce "nextcloud &" spawnOnce "nextcloud &"
spawnOnce "slack &" -- spawnOnce "slack &"
spawnOnce "todoist &" -- spawnOnce "todoist &"
-- Start trayer last -- Start trayer last
spawnOnce "trayer --edge top --align right --widthtype request --padding 6 --SetDockType true --SetPartialStrut true --expand true --monitor 1 --transparent true --alpha 0 --tint 0x121e32 --height 24 &" spawnOnce "trayer --edge top --align right --widthtype request --padding 6 --SetDockType true --SetPartialStrut true --expand true --monitor 1 --transparent true --alpha 0 --tint 0x121e32 --height 20 &"
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -536,12 +536,12 @@ main = do
mouseBindings = myMouseBindings, mouseBindings = myMouseBindings,
-- hooks, layouts -- hooks, layouts
layoutHook = showWName' myShowWNameTheme $ myLayout, layoutHook = showWName' myShowWNameTheme myLayout,
manageHook = ( isFullscreen --> doFullFloat ) <+> myManageHook <+> manageDocks, manageHook = ( isFullscreen --> doFullFloat ) <+> myManageHook <+> manageDocks,
handleEventHook = myEventHook <+> fullscreenEventHook, handleEventHook = myEventHook <+> fullscreenEventHook,
-- logHook = myLogHook, -- logHook = myLogHook,
logHook = myLogHook <+> dynamicLogWithPP xmobarPP logHook = myLogHook <+> dynamicLogWithPP xmobarPP
{ ppOutput = \x -> hPutStrLn xmproc x { ppOutput = hPutStrLn xmproc
, ppCurrent = xmobarColor "#a8de45" "" . wrap "[" "]" -- Current workspace in xmobar , ppCurrent = xmobarColor "#a8de45" "" . wrap "[" "]" -- Current workspace in xmobar
, ppVisible = xmobarColor "#88ae55" "" . clickable -- Visible but not current workspace , ppVisible = xmobarColor "#88ae55" "" . clickable -- Visible but not current workspace
, ppHidden = xmobarColor "#82AAFF" "" . wrap "*" "" . clickable -- Hidden workspaces in xmobar , ppHidden = xmobarColor "#82AAFF" "" . wrap "*" "" . clickable -- Hidden workspaces in xmobar