audio fn keys

This commit is contained in:
qvalentin 2021-10-08 18:15:05 +02:00
parent 8f212ce394
commit 995541b03d
1 changed files with 110 additions and 30 deletions

140
xmonad.hs
View File

@ -1,22 +1,97 @@
import Control.Monad (liftM2) import Control.Monad (liftM2)
import Data.List (isInfixOf)
import qualified Data.Monoid import qualified Data.Monoid
import XMonad import XMonad
import XMonad.Actions.WindowGo ( ChangeLayout (NextLayout),
Default (def),
Full (Full),
Mirror (Mirror),
MonadReader (reader),
Query,
Tall (Tall),
WindowSet,
WindowSpace,
X,
XConfig
( borderWidth,
focusedBorderColor,
layoutHook,
logHook,
manageHook,
modMask,
normalBorderColor,
startupHook,
terminal,
workspaces
),
className,
composeAll,
doF,
doFloat,
doIgnore,
doShift,
mod4Mask,
resource,
sendMessage,
spawn,
title,
withWindowSet,
xmonad,
(-->),
(<&&>),
(<+>),
(=?),
(|||),
)
import XMonad.Actions.WindowGo (raise, runOrRaise)
import XMonad.Hooks.DynamicLog import XMonad.Hooks.DynamicLog
( PP
( ppCurrent,
ppExtras,
ppHidden,
ppHiddenNoWindows,
ppOrder,
ppSep,
ppSort,
ppTitleSanitize,
ppUrgent
),
shorten,
wrap,
xmobarBorder,
xmobarColor,
xmobarRaw,
xmobarStrip,
)
import XMonad.Hooks.EwmhDesktops import XMonad.Hooks.EwmhDesktops
( activateLogHook,
ewmh,
ewmhFullscreen,
)
import XMonad.Hooks.InsertPosition (Focus (Newer), Position (End), insertPosition)
import XMonad.Hooks.StatusBar import XMonad.Hooks.StatusBar
( defToggleStrutsKey,
statusBarProp,
withEasySB,
)
import qualified XMonad.Layout.LayoutModifier import qualified XMonad.Layout.LayoutModifier
import XMonad.Layout.Spacing import XMonad.Layout.Spacing
( Border (Border),
Spacing,
spacingRaw,
)
import XMonad.Layout.WindowNavigation import XMonad.Layout.WindowNavigation
import XMonad.StackSet (Workspace (tag), currentTag, integrate', stack, greedyView, shift, focusWindow) ( Direction2D (L, R),
import XMonad.Util.EZConfig Navigate (Go),
import XMonad.Util.Loggers windowNavigation,
import XMonad.Util.SpawnOnce )
import XMonad.Util.Ungrab import XMonad.StackSet (Workspace (tag), currentTag, focusWindow, greedyView, integrate', shift, stack)
import XMonad.Util.EZConfig (additionalKeysP)
import XMonad.Util.Loggers (logTitles)
import XMonad.Util.SpawnOnce (spawnOnce)
import XMonad.Util.Ungrab (unGrab)
import XMonad.Util.WorkspaceCompare (getSortByIndex) import XMonad.Util.WorkspaceCompare (getSortByIndex)
import XMonad.Hooks.InsertPosition (insertPosition, Position(Master, End), Focus (Newer)) import XMonad.Hooks.RefocusLast (RecentWins(previous))
import XMonad.Hooks.ManageHelpers
import Data.List (isInfixOf)
main :: IO () main :: IO ()
main = do main = do
@ -33,34 +108,39 @@ main = do
workspaces = myWorkspaces, workspaces = myWorkspaces,
manageHook = myManageHook, manageHook = myManageHook,
layoutHook = myLayout, layoutHook = myLayout,
logHook = activateLogHook (reader focusWindow >>= doF)<+> logHook def logHook = activateLogHook (reader focusWindow >>= doF) <+> logHook def
} }
`additionalKeysP` [ ("M-S-z", spawn "xscreensaver-command -lock"), `additionalKeysP` [ ("M-S-z", spawn "xscreensaver-command -lock"),
("M-S-s", unGrab *> spawn "cast_screenshot"), ("M-S-s", unGrab *> spawn "cast_screenshot"),
("M-f", runOrRaise "brave" (className =? "Brave-browser")), ("M-f", runOrRaise "brave" (className =? "Brave-browser")),
("M-i", raise (className =? "jetbrains-idea")), ("M-i", raise (className =? "jetbrains-idea")),
("M-<Space>", spawn "rofi -show drun"),
("M-<Space>", spawn "rofi -show drun") , ("M-p", spawn "dmen"),
("M-p", spawn "dmen") ,
-- audio settings -- audio settings
("<XF86AudioLowerVolume>", spawn "amixer set Master 5%- unmute"), ("<XF86AudioLowerVolume>", spawn "amixer set Master 5%- unmute"),
("<XF86AudioRaiseVolume>", spawn "amixer set Master 5%+ unmute"), ("<XF86AudioRaiseVolume>", spawn "amixer set Master 5%+ unmute"),
("<XF86AudioMute>", spawn "amixer set Master toggle"), ("<XF86AudioMute>", spawn "amixer set Master toggle"),
("<XF86AudioPlay>", spawn "playerctl play-pause"),
("<XF86AudioPrev>", spawn "playerctl previous"),
("<XF86AudioNext>", spawn "playerctl next"),
-- window navigation -- window navigation
("M-l", sendMessage $ Go R), ("M-l", sendMessage $ Go R),
("M-h", sendMessage $ Go L), ("M-h", sendMessage $ Go L),
-- layout switching -- layout switching
("M-<Tab>", sendMessage NextLayout), ("M-<Tab>", sendMessage NextLayout),
-- dmenu stuff -- dmenu stuff
("M1-<F4>", spawn "dshutdown") ("M1-<F4>", spawn "powerbutton"),
-- lockscreen
("M-<Escape>",spawn "betterlockscreen -l")
] ]
myXmobarPP :: [String] -> PP myXmobarPP :: [String] -> PP
myXmobarPP colors = myXmobarPP colors =
def def
{ ppSep = walXmobarColor 1 "", { ppSep = walXmobarColor 1 "",
ppTitleSanitize = xmobarStrip, ppTitleSanitize = xmobarStrip,
ppCurrent = wrap " " "" . xmobarBorder "Top" (colors!!6) 2, ppCurrent = wrap " " "" . xmobarBorder "Top" (colors !! 6) 2,
ppHidden = white . wrap " " "", ppHidden = white . wrap " " "",
ppHiddenNoWindows = white . wrap " " "", ppHiddenNoWindows = white . wrap " " "",
ppUrgent = red . wrap (yellow "!") (yellow "!"), ppUrgent = red . wrap (yellow "!") (yellow "!"),
@ -69,9 +149,9 @@ myXmobarPP colors =
ppSort = hideWorkspaces ppSort = hideWorkspaces
} }
where where
formatFocused = wrap (white "[") (white "]") . walXmobarColor 7. ppWindow formatFocused = wrap (white "[") (white "]") . walXmobarColor 7 . ppWindow
formatUnfocused = wrap (lowWhite "[") (lowWhite "]") .walXmobarColor 4. ppWindow formatUnfocused = wrap (lowWhite "[") (lowWhite "]") . walXmobarColor 4 . ppWindow
walXmobarColor index = xmobarColor (colors!!index) "" walXmobarColor index = xmobarColor (colors !! index) ""
ppWindow :: String -> String ppWindow :: String -> String
ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w) . shorten 30 ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w) . shorten 30
@ -90,13 +170,13 @@ myXmobarPP colors =
thefilter = do thefilter = do
currentWS <- withWindowSet (pure . currentTag) currentWS <- withWindowSet (pure . currentTag)
return $ reverse . dropWhile (liftM2 (&&) ((currentWS /=) . tag) isEmptyWs) . reverse return $ reverse . dropWhile (liftM2 (&&) ((currentWS /=) . tag) isEmptyWs) . reverse
where isEmptyWs workspace = null $ integrate' $ stack workspace
isEmptyWs workspace = null $ integrate' $ stack workspace
myStartupHook :: X () myStartupHook :: X ()
myStartupHook = do myStartupHook = do
spawnOnce "picom &" spawnOnce "picom &"
spawnOnce "sh $HOME/.fehbg" spawnOnce "sh $HOME/.fehbg"
spawnOnce "websocketd --port=8974 wnpClient &"
getWalColors :: IO [String] getWalColors :: IO [String]
getWalColors = do getWalColors = do
@ -112,13 +192,12 @@ mySpacing' i = spacingRaw True (Border i 0 i i) True (Border i 0 i i) True
myWorkspaces :: [String] myWorkspaces :: [String]
myWorkspaces = show <$> [1 .. 9] myWorkspaces = show <$> [1 .. 9]
myLayout = windowNavigation tiled ||| Mirror tiled ||| Full myLayout = windowNavigation tiled ||| Mirror tiled ||| Full
where where
tiled = mySpacing' 8 $ Tall nmaster delta ratio tiled = mySpacing' 8 $ Tall nmaster delta ratio
nmaster = 1 -- Default number of windows in the master pane nmaster = 1 -- Default number of windows in the master pane
ratio = 1/2 -- Default proportion of screen occupied by master pane ratio = 1 / 2 -- Default proportion of screen occupied by master pane
delta = 3/100 -- Percent of screen to increment by when resizing panes delta = 3 / 100 -- Percent of screen to increment by when resizing panes
myManageHook :: XMonad.Query (Data.Monoid.Endo WindowSet) myManageHook :: XMonad.Query (Data.Monoid.Endo WindowSet)
myManageHook = myManageHook =
@ -142,13 +221,14 @@ myManageHook =
title =? "Signal" --> viewShift (myWorkspaces !! 2), title =? "Signal" --> viewShift (myWorkspaces !! 2),
className =? "TelegramDesktop" --> viewShift (myWorkspaces !! 2), className =? "TelegramDesktop" --> viewShift (myWorkspaces !! 2),
className =? "Gimp" --> doShift (myWorkspaces !! 8), className =? "Gimp" --> doShift (myWorkspaces !! 8),
className =? "VirtualBox Manager" --> doShift (myWorkspaces !! 4),
(className =? "firefox" <&&> resource =? "Dialog") --> doFloat, -- Float Firefox Dialog (className =? "firefox" <&&> resource =? "Dialog") --> doFloat, -- Float Firefox Dialog
className =? "jetbrains-idea" --> viewShift (myWorkspaces !! 4) , className =? "alfaview" --> viewShift (myWorkspaces !! 5),
className =? "jetbrains-idea" --> viewShift (myWorkspaces !! 4),
(className =? "jetbrains-studio") <&&> (title ~=? "win") --> doIgnore (className =? "jetbrains-studio") <&&> (title ~=? "win") --> doIgnore
] <+> insertPosition End Newer ]
where viewShift = doF . liftM2 (.) greedyView shift <+> insertPosition End Newer
where
viewShift = doF . liftM2 (.) greedyView shift
-- IntelliJ fix -- IntelliJ fix
(~=?) :: Eq a => Query [a] -> [a] -> Query Bool (~=?) :: Eq a => Query [a] -> [a] -> Query Bool