mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
vanadium: move xmonad config
This commit is contained in:
parent
ef4aa7d5db
commit
0342f5e87c
6 changed files with 4 additions and 1 deletions
|
|
@ -1,296 +0,0 @@
|
|||
{-# LANGUAGE NegativeLiterals #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# LANGUAGE BlockArguments #-}
|
||||
|
||||
import XMonad
|
||||
|
||||
import XMonad.Actions.SwapWorkspaces(swapWithCurrent)
|
||||
import XMonad.Actions.Submap (submap)
|
||||
|
||||
import XMonad.Util.EZConfig (additionalKeys, removeKeys)
|
||||
import XMonad.Util.NamedScratchpad (NamedScratchpad (NS),
|
||||
customFloating,
|
||||
namedScratchpadAction,
|
||||
namedScratchpadManageHook, scratchpadWorkspaceTag)
|
||||
import XMonad.Util.SpawnOnce (spawnOnce)
|
||||
|
||||
import XMonad.Layout.NoBorders (smartBorders)
|
||||
import XMonad.Layout.Reflect (reflectHoriz)
|
||||
import XMonad.Layout.Spacing (smartSpacingWithEdge)
|
||||
import XMonad.Layout.ResizableTile (ResizableTall(ResizableTall), MirrorResize (MirrorShrink, MirrorExpand))
|
||||
|
||||
import XMonad.Hooks.ManageHelpers (isFullscreen, (~?), composeOne, (-?>))
|
||||
import XMonad.Hooks.FadeWindows (fadeWindowsLogHook, opaque, isUnfocused, transparency, isFloating)
|
||||
import XMonad.Hooks.EwmhDesktops (ewmh, ewmhFullscreen)
|
||||
import XMonad.Hooks.InsertPosition (insertPosition, Focus(Newer, Older), Position(Below, Above))
|
||||
import XMonad.Hooks.RefocusLast (refocusLastLogHook)
|
||||
import XMonad.Hooks.StatusBar (StatusBarConfig, statusBarProp, dynamicEasySBs)
|
||||
import XMonad.Hooks.DynamicLog (PP(ppHiddenNoWindows, ppCurrent, ppSep), xmobarColor, filterOutWsPP, wrap)
|
||||
|
||||
import XMonad.Util.Hacks (javaHack)
|
||||
|
||||
import XMonad.StackSet qualified as W
|
||||
|
||||
|
||||
import Data.Map.Strict qualified as M
|
||||
import Graphics.X11.ExtraTypes.XF86
|
||||
import System.Posix.Env (putEnv)
|
||||
|
||||
|
||||
import Leanamonad.Layouts.ReflectMsg
|
||||
import Leanamonad.GreekChar
|
||||
|
||||
|
||||
|
||||
-- Note: `xmonad --restart` will make Firefox's fullscreen work duck the xmobar stop working
|
||||
-- You need restart Firefox
|
||||
main :: IO ()
|
||||
main = xmonad
|
||||
-- Fix all java things that don't scale with XMonad
|
||||
-- https://wiki.archlinux.org/title/java#Gray_window,_applications_not_resizing_with_WM,_menus_immediately_closing
|
||||
. javaHack
|
||||
. dynamicEasySBs xmobar
|
||||
. ewmhFullscreen . ewmh
|
||||
$ def
|
||||
{ modMask = superMask
|
||||
, borderWidth = 5
|
||||
, normalBorderColor = "#18005f"
|
||||
, focusedBorderColor = "#875fff"
|
||||
, focusFollowsMouse = True
|
||||
, terminal = myTerm
|
||||
, workspaces = myWorkspaces
|
||||
|
||||
, logHook =
|
||||
let
|
||||
fadeHook =
|
||||
composeAll
|
||||
[ opaque
|
||||
|
||||
, className ~? "steam" --> opaque
|
||||
|
||||
-- Based on state
|
||||
, isUnfocused --> transparency 0.08
|
||||
, isFloating --> transparency 0.08
|
||||
|
||||
, isFirefoxFullscreen --> opaque
|
||||
, isFirefoxPIP --> opaque
|
||||
, isFirefoxVideo --> opaque
|
||||
]
|
||||
in
|
||||
fadeWindowsLogHook fadeHook
|
||||
<+> refocusLastLogHook
|
||||
|
||||
, startupHook = do
|
||||
spawnOnce "fcitx5 &" -- Input method
|
||||
spawn "feh --no-fehbg --bg-fill ~/.wallpaper &" -- wallpaper
|
||||
|
||||
io $ do
|
||||
putEnv "QT_SCALE_FACTOR=1.25" -- Fix problem where digikam is too small
|
||||
-- https://bugs.kde.org/show_bug.cgi?id=427662
|
||||
|
||||
putEnv "GLFW_IM_MODULE=ibus" -- Make sure kitty knows how to talk to fcitx
|
||||
putEnv "MOZ_USE_XINPUT2=1" -- Force touchpad for firefox
|
||||
|
||||
spawn "dbus-update-activation-environment DISPLAY XAUTHORITY WAYLAND_DISPLAY"
|
||||
|
||||
, layoutHook =
|
||||
let tallr = reflectMsg . reflectHoriz
|
||||
$ ResizableTall 1 (1/10) (3/7) []
|
||||
in smartBorders
|
||||
( smartSpacingWithEdge 5 tallr
|
||||
||| Full
|
||||
)
|
||||
|
||||
, manageHook =
|
||||
let
|
||||
hasEvenWindows :: X Bool
|
||||
hasEvenWindows = g <$> get
|
||||
where g =
|
||||
even . length . W.integrate'
|
||||
. W.stack . W.workspace . W.current . windowset
|
||||
in
|
||||
composeAll
|
||||
[ className ~? "blueman-manager" --> customFloating smallFloat
|
||||
, className ~? "NautilusPreviewer" --> customFloating centeredFloat
|
||||
, className =? "feh" --> doFloat
|
||||
, isFirefoxPIP --> doFloat
|
||||
|
||||
, namedScratchpadManageHook myScratchpads
|
||||
]
|
||||
|
||||
<+>
|
||||
composeOne
|
||||
[ className =? "firefox" -?> insertPosition Above Newer
|
||||
, className =? "sioyek" -?> insertPosition Below Older
|
||||
, className =? "kitty" -?> insertPosition Below Newer
|
||||
, className ~? "Nautilus" -?> insertPosition Below Older -- For some reason Older doesn't work
|
||||
|
||||
, ifM
|
||||
(liftX hasEvenWindows)
|
||||
(Just <$> insertPosition Below Newer) -- New window is odd
|
||||
(Just <$> insertPosition Above Newer) -- New window is even
|
||||
]
|
||||
}
|
||||
|
||||
-- Only remove mappings that needs pass through (it's a map).
|
||||
`removeKeys`
|
||||
[ (superMask, xK_h)
|
||||
, (superMask, xK_l)
|
||||
, (superMask, xK_p)
|
||||
|
||||
-- It has been more than once that I actidently killed xmonad >:(
|
||||
, (superMask .|. shiftMask, xK_q)
|
||||
]
|
||||
++ [ (superMask , n) | n <- [xK_1 .. xK_9] ]
|
||||
++ [ (superMask .|. shiftMask, n) | n <- [xK_1 .. xK_9] ]
|
||||
|
||||
`additionalKeys`
|
||||
[
|
||||
-- Display
|
||||
((0 , xF86XK_MonBrightnessDown), spawn "light -U 5")
|
||||
, ((0 , xF86XK_MonBrightnessUp ), spawn "light -A 5")
|
||||
, ((altMask, xF86XK_MonBrightnessDown), spawn "light -U 1")
|
||||
, ((altMask, xF86XK_MonBrightnessUp ), spawn "light -A 1")
|
||||
|
||||
-- Volume adjustments
|
||||
-- Don't overload the mute button
|
||||
-- In case of doubt, smashing the button becomes deterministic
|
||||
, ((0, xF86XK_AudioMute), spawn "pactl -- set-sink-mute 0 1" ) -- mute
|
||||
, ((controlMask, xF86XK_AudioMute), spawn "pactl -- set-sink-mute 0 0" ) -- unmute
|
||||
, ((0, xF86XK_AudioLowerVolume), spawn "pactl -- set-sink-volume 0 -5%")
|
||||
, ((0, xF86XK_AudioRaiseVolume), spawn "pactl -- set-sink-volume 0 +5%")
|
||||
, ((altMask, xF86XK_AudioLowerVolume), spawn "pactl -- set-sink-volume 0 -1%")
|
||||
, ((altMask, xF86XK_AudioRaiseVolume), spawn "pactl -- set-sink-volume 0 +1%")
|
||||
|
||||
-- Playback control
|
||||
, ((0, xF86XK_AudioPrev), spawn "playerctl previous" )
|
||||
, ((0, xF86XK_AudioPlay), spawn "playerctl play-pause")
|
||||
, ((0, xF86XK_AudioNext), spawn "playerctl next" )
|
||||
|
||||
-- Toggle fullscreen
|
||||
, ((superMask, xK_Escape), sendMessage NextLayout)
|
||||
|
||||
-- Resize windows
|
||||
, ((superMask, xK_equal ), sendMessage $ IncMasterN 1)
|
||||
, ((superMask, xK_minus ), sendMessage $ IncMasterN -1)
|
||||
, ((superMask, xK_comma ), sendMessage Shrink )
|
||||
, ((superMask, xK_period ), sendMessage Expand )
|
||||
, ((superMask .|. shiftMask, xK_comma ), sendMessage MirrorShrink )
|
||||
, ((superMask .|. shiftMask, xK_period), sendMessage MirrorExpand )
|
||||
|
||||
-- [D]o sink and lift
|
||||
, ( (superMask, xK_d)
|
||||
, submap $ M.fromList
|
||||
[ ((0, xK_t), withFocused $ windows . W.sink)
|
||||
, ((0, xK_l), withFocused $ windows . flip W.float centeredFloat)
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
-- Screenshots
|
||||
++ (let
|
||||
fullscreen = "shotgun -s - | xclip -in -selection clipboard -t image/png"
|
||||
withSelection = "shotgun -g $(hacksaw -c \"#875fff\" -g 3) - | xclip -in -selection clipboard -t image/png"
|
||||
toFloat = "shotgun -g $(hacksaw -c \"#875fff\" -g 3) - | feh --auto-zoom -"
|
||||
in
|
||||
[ ((0, xK_Print), spawn fullscreen )
|
||||
, ((superMask .|. shiftMask, xK_3 ), spawn fullscreen )
|
||||
, ((superMask .|. shiftMask, xK_4 ), spawn withSelection)
|
||||
, ((superMask .|. shiftMask, xK_5 ), spawn toFloat )
|
||||
])
|
||||
|
||||
-- Yeet
|
||||
++ (let
|
||||
workspaceKeys = [xK_h, xK_t, xK_n, xK_s, xK_m, xK_w, xK_v, xK_z]
|
||||
in
|
||||
[ ((superMask, k), windows $ W.greedyView space)
|
||||
| (k, space) <- zip workspaceKeys myWorkspaces
|
||||
]
|
||||
++
|
||||
[ ((superMask .|. altMask, k), windows $ W.greedyView space . W.shift space)
|
||||
| (k, space) <- zip workspaceKeys myWorkspaces
|
||||
]
|
||||
++
|
||||
[ ((superMask .|. controlMask, k), windows $ swapWithCurrent space)
|
||||
| (k, space) <- zip workspaceKeys myWorkspaces
|
||||
])
|
||||
|
||||
-- Launcher
|
||||
++ (let
|
||||
launchFirefox = "if type firefox; then firefox; else firefox-esr; fi"
|
||||
launchDmenu = "dmenu_run -i -fn \"Iosevka Extended-17\" -nb \"#36363a\" -nf \"#e2e2e4\" -sb \"#f7f7f8\" -sf \"#36363a\" -l 10"
|
||||
lock = "xscreensaver-command -lock"
|
||||
in
|
||||
[ ((controlMask .|. altMask, xK_m), namedScratchpadAction myScratchpads "cmus" )
|
||||
, ((controlMask .|. altMask, xK_t), namedScratchpadAction myScratchpads "btop" )
|
||||
, ((controlMask .|. altMask, xK_p), namedScratchpadAction myScratchpads "pass" )
|
||||
, ((controlMask .|. altMask, xK_r), namedScratchpadAction myScratchpads "ranger")
|
||||
, ((controlMask .|. altMask, xK_b), spawn launchFirefox )
|
||||
, ((superMask, xK_o), spawn launchDmenu )
|
||||
, ((superMask, xK_l), spawn lock )
|
||||
])
|
||||
|
||||
myTerm :: String
|
||||
myTerm = "kitty"
|
||||
|
||||
superMask, altMask :: KeyMask
|
||||
superMask = mod4Mask
|
||||
altMask = mod1Mask
|
||||
|
||||
myWorkspaces :: [String]
|
||||
myWorkspaces = take 8 . fmap (:[]) $ greekLower
|
||||
|
||||
centeredFloat, smallFloat, fullFloat :: W.RationalRect
|
||||
centeredFloat = W.RationalRect (1/9) (1/9) (7/9) (7/9)
|
||||
smallFloat = W.RationalRect (3/5) (3/5) (2/7) (2/7)
|
||||
fullFloat = W.RationalRect 0 0 1 1
|
||||
|
||||
xmobar :: ScreenId -> X StatusBarConfig
|
||||
xmobar = \case
|
||||
0 -> pure $ statusBarProp "xmobar -x 0" (pure myPrettyPrinter)
|
||||
1 -> pure $ statusBarProp "xmobar -x 1" (pure myPrettyPrinter)
|
||||
_ -> mempty
|
||||
where
|
||||
myPrettyPrinter =
|
||||
filterOutWsPP [scratchpadWorkspaceTag]
|
||||
$ def
|
||||
{ ppCurrent = xmobarColor "#000000" "#ffffff" . wrap " " " " . fmap toUpper
|
||||
, ppHiddenNoWindows = xmobarColor "#9c9c9c" "" . const "⋅"
|
||||
, ppSep = " | "
|
||||
}
|
||||
|
||||
isFirefoxPIP :: Query Bool
|
||||
isFirefoxPIP =
|
||||
className =? "firefox"
|
||||
<&&> title =? "Picture-in-Picture"
|
||||
|
||||
isFirefoxFullscreen :: Query Bool
|
||||
isFirefoxFullscreen =
|
||||
className =? "firefox"
|
||||
<&&> isFullscreen
|
||||
|
||||
-- Firefox having multimedia content
|
||||
isFirefoxVideo :: Query Bool
|
||||
isFirefoxVideo =
|
||||
className =? "firefox"
|
||||
<&&> title ~? "YouTube"
|
||||
|
||||
myScratchpads :: [NamedScratchpad]
|
||||
myScratchpads =
|
||||
[ NS "cmus"
|
||||
(myTerm ++ " -T 'cmus' cmus")
|
||||
(title =? "cmus")
|
||||
(customFloating centeredFloat)
|
||||
, NS "btop"
|
||||
(myTerm ++ " -T 'btop' btop")
|
||||
(title =? "btop")
|
||||
(customFloating fullFloat)
|
||||
, NS "pass"
|
||||
(myTerm ++ " -T 'pass' -- fish -i -c 'while :; fzf-pass; end'")
|
||||
(title =? "pass")
|
||||
(customFloating smallFloat)
|
||||
, NS "ranger"
|
||||
(myTerm ++ " -o font_size=18 -T 'ranger' -- fish -c 'exec ranger ~/Documents'" {- makes sure $VISUAL and $EDITOR is propagated -})
|
||||
(title =? "ranger")
|
||||
(customFloating centeredFloat)
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue