chore: Changed xmobar look to be cleaner

This commit is contained in:
Afonso Franco 2022-10-31 21:00:11 +00:00
parent 9630e6b6f6
commit 40805cf02d
Signed by: afonso
SSH key fingerprint: SHA256:gkVPzsQQJzqi21ntQBV6pXTx4bYI53rFGI4XtvCpwd4
21 changed files with 900 additions and 150 deletions

View file

@ -16,3 +16,10 @@ color05 = "#02CB9E"
colorTrayer :: String
colorTrayer = "--tint 0x282c34"
grey1 = "#2B2E37"
grey2 = "#555E70"
grey3 = "#697180"
grey4 = "#8691A8"
cyan = "#8BABF0"
orange = "#C45500"

244
.config/xmonad/xmonad.hs Normal file
View file

@ -0,0 +1,244 @@
{-# OPTIONS_GHC -Wno-deprecations #-}
import XMonad
import XMonad.Util.EZConfig (additionalKeysP,removeKeysP)
import XMonad.Hooks.DynamicLog
import XMonad.Util.Loggers (logLayoutOnScreen, logTitleOnScreen, shortenL, wrapL, xmobarColorL)
import XMonad.Hooks.SetWMName
import XMonad.Actions.SpawnOn
import XMonad.Hooks.StatusBar
import qualified XMonad.StackSet as W
import XMonad.Hooks.EwmhDesktops
import XMonad.Util.Run
import Data.Maybe (fromJust)
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import Data.Monoid
import Colors.Teal
import System.Exit
import XMonad.Util.SpawnOnce
import XMonad.Layout.Spacing
--import XMonad.Layout.Fullscreen
import qualified XMonad.StackSet as W
import qualified Data.Map as M
myTerminal = "alacritty"
myTextEditor = "vim"
myWebBrowser = "firefox"
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
myClickJustFocuses :: Bool
myClickJustFocuses = False
windowCount :: X (Maybe String)
windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace . W.current . windowset
myNormalBorderColor = "#008080"
myFocusedBorderColor = "#01F9C6"
myBorderWidth = 2
myWorkspaces = ["main","web","text","code","social","mail"]
myWorkspaceIndices = M.fromList $ zipWith (,) myWorkspaces [1..]
myModMask = mod4Mask
myKeys :: [(String, X ())]
myKeys =
[ ("M-x" ,spawn myTerminal )
, ("M-p", spawn "rofi -show drun")
, ("M-b", spawn myWebBrowser)
, ("<Print>", spawn "flameshot screen")
, ("S-<Print>", spawn "flameshot gui")
, ("<XF86AudioMute>", spawn "pamixer set --toggle-mute")
, ("<XF86AudioLowerVolume>", spawn "pamixer -d 5")
, ("<XF86AudioRaiseVolume>", spawn "pamixer -i 5")
,("<xf86monbrightnessup>", spawn "lux -a 10%")
,("<xf86monbrightnessdown>", spawn "lux -s 10%")
,("M-n", spawn $ myTerminal ++ " -e nmtui")
, ("M-q", kill)
, ("M-S-<Space>", sendMessage NextLayout)
, ("M-<Down>", windows W.focusDown)
, ("M-<Up>", windows W.focusUp )
, ("M-m", windows W.focusMaster )
, ("M-<Return>", windows W.swapMaster)
, ("M-h", sendMessage Shrink)
, ("M-l", sendMessage Expand)
, ("M-t", withFocused $ windows . W.sink)
, ("M-S-u", io (exitWith ExitSuccess))
, ("M-u", spawn "xmonad --recompile; xmonad --restart")
]
++
[("M-" ++ m ++ (show k), windows $ f i)
| (i, k) <- zip myWorkspaces [1..]
, (f, m) <- [(W.greedyView, "0"), (W.shift, "S-")]]
++
[("M-" ++ m ++ key, screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip ["w", "e", "r"] [0..]
, (f, m) <- [(W.view, "0"), (W.shift, "S-")]]
myRemoveKeys = ["M-S-<Return>","M-S-p","M-S-c","M-<Space>","M-n","M-S-q"]
myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
[ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
>> windows W.shiftMaster))
, ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
, ((modm, button3), (\w -> focus w >> mouseResizeWindow w
>> windows W.shiftMaster))]
myLayout = avoidStruts(tiled ||| Mirror tiled ||| Full)
where
tiled = Tall nmaster delta ratio
nmaster = 1
ratio = 1/2
delta = 3/100
myManageHook = composeAll
[ className =? "MPlayer" --> doFloat
, className =? "Gimp" --> doFloat
, resource =? "desktop_window" --> doIgnore
, className =? "QjackCtl" --> doFloat
, resource =? "kdesktop" --> doIgnore
, className =? "firefox" --> doShift (myWorkspaces !! 1)
, className =? "Code" --> doShift (myWorkspaces !! 3)
, className =? "discord" --> doShift (myWorkspaces !! 4)
, title =? "JetBrains Toolbox" --> doShift (myWorkspaces !! 3)
, className =? "main" --> doFloat
, className =? "Mailspring" --> doShift (myWorkspaces !! 5)
, className =? "Xmessage" --> doFloat
, isFullscreen --> doFullFloat]
myEventHook = ewmhDesktopsEventHook
myStartupHook = do
spawn "setxkbmap -layout us,pt"
spawn "setxkbmap -option grp:win_space_toggle"
spawn "setxkbmap -option caps:escape"
spawnOnce "pasystray"
spawnOnce "nitrogen --restore &"
spawnOnce "picom &"
spawnOnce "optimus-manager-qt"
setWMName "LG3D"
spawnOnce "nm-applet"
spawnOnce "mailspring"
spawnOnce "qjackctl"
spawnOnce("xsetroot -cursor_name left_ptr")
spawn ("killall trayer ;sleep 1 && trayer --edge top --align right --widthtype request --margin 6 --padding 4 --SetDockType true --SetPartialStrut true --iconspacing 12 --expand true --monitor 0 --transparent true --alpha 0 " ++ colorTrayer ++ " --height 32 --distance 20 --distancefrom right")
spawnOn "web" myWebBrowser
spawnOn "main" myTerminal
actionPrefix, actionButton, actionSuffix :: [Char]
actionPrefix = "<action=`xdotool key super+"
actionButton = "` button="
actionSuffix = "</action>"
addActions :: [(String, Int)] -> String -> String
addActions [] ws = ws
addActions (x:xs) ws = addActions xs (actionPrefix ++ k ++ actionButton ++ show b ++ ">" ++ ws ++ actionSuffix)
where k = fst x
b = snd x
clickable :: [Char] -> [Char] -> [Char]
clickable icon ws = addActions [ (show i, 1), ("q", 2), ("Left", 4), ("Right", 5) ] icon
where i = fromJust $ M.lookup ws myWorkspaceIndices
myStatusBarSpawner :: Applicative f => ScreenId -> f StatusBarConfig
myStatusBarSpawner (S s) = do
pure $ statusBarPropTo ("_XMONAD_LOG_" ++ show s)
("xmobar -x " ++ show s ++ " ~/.config/xmobar/xmobarrc" ++ show s ++ ".hs")
(pure $ myXmobarPP (S s))
myXmobarPP :: ScreenId -> PP
myXmobarPP s = def
{ ppSep = ""
, ppWsSep = ""
, ppCurrent = xmobarColor cyan "" . clickable wsIconFull
, ppVisible = xmobarColor grey4 "" . clickable wsIconFull
, ppVisibleNoWindows = Just (xmobarColor grey4 "" . clickable wsIconFull)
, ppHidden = xmobarColor grey2 "" . clickable wsIconHidden
, ppHiddenNoWindows = xmobarColor grey2 "" . clickable wsIconEmpty
, ppUrgent = xmobarColor orange "" . clickable wsIconFull
, ppOrder = \(ws : _ : _ : extras) -> ws : extras
, ppExtras = [ wrapL (actionPrefix ++ "n" ++ actionButton ++ "1>") actionSuffix
$ wrapL (actionPrefix ++ "q" ++ actionButton ++ "2>") actionSuffix
$ wrapL (actionPrefix ++ "Left" ++ actionButton ++ "4>") actionSuffix
$ wrapL (actionPrefix ++ "Right" ++ actionButton ++ "5>") actionSuffix
$ wrapL " " " " $ layoutColorIsActive s (logLayoutOnScreen s)
, wrapL (actionPrefix ++ "q" ++ actionButton ++ "2>") actionSuffix
$ titleColorIsActive s (shortenL 81 $ logTitleOnScreen s)
]
}
where
wsIconFull = " <fn=2>\xf111</fn> "
wsIconHidden = " <fn=2>\xf111</fn> "
wsIconEmpty = " <fn=2>\xf10c</fn> "
titleColorIsActive n l = do
c <- withWindowSet $ return . W.screen . W.current
if n == c then xmobarColorL cyan "" l else xmobarColorL grey3 "" l
layoutColorIsActive n l = do
c <- withWindowSet $ return . W.screen . W.current
if n == c then wrapL "<icon=/home/afonso/.config/xmobar/xpm/" "_selected.xpm/>" l else wrapL "<icon=/home/afonso/.config/xmobar/xpm/" ".xpm/>" l
myConfig = def
{
terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse,
clickJustFocuses = myClickJustFocuses,
borderWidth = myBorderWidth,
modMask = myModMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- keys = myKeys,
layoutHook = spacingWithEdge 10 $ myLayout,
manageHook = manageSpawn <+> myManageHook <+> manageHook def,
handleEventHook = myEventHook <+> fullscreenEventHook,
startupHook = myStartupHook}
main :: IO ()
main = do
xmonad . ewmh . ewmhFullscreen . dynamicSBs myStatusBarSpawner . docks $ additionalKeysP (removeKeysP myConfig myRemoveKeys) myKeys
help :: String
help = unlines ["The default modifier key is 'alt'. Default keybindings:",
"",
"-- launching and killing programs",
"mod-Shift-Enter Launch xterminal",
"mod-p Launch dmenu",
"mod-Shift-p Launch gmrun",
"mod-Shift-c Close/kill the focused window",
"mod-Space Rotate through the available layout algorithms",
"mod-Shift-Space Reset the layouts on the current workSpace to default",
"mod-n Resize/refresh viewed windows to the correct size",
"",
"-- move focus up or down the window stack",
"mod-Tab Move focus to the next window",
"mod-Shift-Tab Move focus to the previous window",
"mod-j Move focus to the next window",
"mod-k Move focus to the previous window",
"mod-m Move focus to the master window",
"",
"-- modifying the window order",
"mod-Return Swap the focused window and the master window",
"mod-Shift-j Swap the focused window with the next window",
"mod-Shift-k Swap the focused window with the previous window",
"",
"-- resizing the master/slave ratio",
"mod-h Shrink the master area",
"mod-l Expand the master area",
"",
"-- floating layer support",
"mod-t Push window back into tiling; unfloat and re-tile it",
"",
"-- increase or decrease number of windows in the master area",
"mod-comma (mod-,) Increment the number of windows in the master area",
"mod-period (mod-.) Deincrement the number of windows in the master area",
"",
"-- quit, or restart",
"mod-Shift-q Quit xmonad",
"mod-q Restart xmonad",
"mod-[1..9] Switch to workSpace N",
"",
"-- Workspaces & screens",
"mod-Shift-[1..9] Move client to workspace N",
"mod-{w,e,r} Switch to physical/Xinerama screens 1, 2, or 3",
"mod-Shift-{w,e,r} Move client to screen 1, 2, or 3",
"",
"-- Mouse bindings: default actions bound to mouse events",
"mod-button1 Set the window to floating mode and move by dragging",
"mod-button2 Raise the window to the top of the stack",
"mod-button3 Set the window to floating mode and resize by dragging"]

View file

@ -16,9 +16,11 @@
import XMonad
import XMonad.Util.EZConfig (additionalKeysP,removeKeysP)
import XMonad.Hooks.DynamicLog (dynamicLogWithPP, wrap, xmobarPP, xmobarColor, shorten, PP(..))
import XMonad.Hooks.DynamicLog
import XMonad.Util.Loggers (logLayoutOnScreen, logTitleOnScreen, shortenL, wrapL, xmobarColorL)
import XMonad.Hooks.SetWMName
import XMonad.Actions.SpawnOn
import XMonad.Hooks.StatusBar
import qualified XMonad.StackSet as W
import XMonad.Hooks.EwmhDesktops
import XMonad.Util.Run
@ -65,9 +67,6 @@
>myWorkspaces = ["main","web","text","code","social","mail"]
>myWorkspaceIndices = M.fromList $ zipWith (,) myWorkspaces [1..]
>clickable ws = "<action=xdotool key super+"++show i++">"++ws++"</action>"
> where i = fromJust $ M.lookup ws myWorkspaceIndices
\subsubsection{Keybindings}
@ -81,7 +80,7 @@
launch rofi
> , ("M-p", spawn "rofi -show run")
> , ("M-p", spawn "rofi -show drun")
launch web browser
@ -236,9 +235,9 @@ Percent of screen to increment by when resizing panes
\subsubsection{Startup Hook}
\begin{code}
myStartupHook = do
spawnOnce "setxkbmap -layout us,pt"
spawnOnce "setxkbmap -option grp:win_space_toggle"
spawnOnce "setxkbmap -option caps:escape"
spawn "setxkbmap -layout us,pt"
spawn "setxkbmap -option grp:win_space_toggle"
spawn "setxkbmap -option caps:escape"
spawnOnce "pasystray"
spawnOnce "nitrogen --restore &"
spawnOnce "picom &"
@ -248,14 +247,71 @@ Percent of screen to increment by when resizing panes
spawnOnce "mailspring"
spawnOnce "qjackctl"
spawnOnce("xsetroot -cursor_name left_ptr")
spawn ("killall trayer && sleep 1 && trayer --edge top --align right --widthtype request --margin 6 --padding 4 --SetDockType true --SetPartialStrut true --iconspacing 12 --expand true --monitor 0 --transparent true --alpha 0 " ++ colorTrayer ++ " --height 22 --distance 58 --distancefrom right")
spawn ("killall trayer ;sleep 1 && trayer --monitor 0 --edge top --align right --widthtype request --padding 7 --iconspacing 12 --SetDockType true --SetPartialStrut true --expand true --transparent true --alpha 0 --tint 0x2B2E37 --height 26 --distance 5 &")
spawnOn "web" myWebBrowser
spawnOn "main" myTerminal
\end{code}
\subsection{Xmobar}
\begin{code}
actionPrefix, actionButton, actionSuffix :: [Char]
actionPrefix = "<action=`xdotool key super+"
actionButton = "` button="
actionSuffix = "</action>"
addActions :: [(String, Int)] -> String -> String
addActions [] ws = ws
addActions (x:xs) ws = addActions xs (actionPrefix ++ k ++ actionButton ++ show b ++ ">" ++ ws ++ actionSuffix)
where k = fst x
b = snd x
clickable :: [Char] -> [Char] -> [Char]
clickable icon ws = addActions [ (show i, 1), ("q", 2), ("Left", 4), ("Right", 5) ] icon
where i = fromJust $ M.lookup ws myWorkspaceIndices
myStatusBarSpawner :: Applicative f => ScreenId -> f StatusBarConfig
myStatusBarSpawner (S s) = do
pure $ statusBarPropTo ("_XMONAD_LOG_" ++ show s)
("xmobar -x " ++ show s ++ " ~/.config/xmobar/xmobarrc" ++ show s)
(pure $ myXmobarPP (S s))
myXmobarPP :: ScreenId -> PP
myXmobarPP s = def
{ ppSep = ""
, ppWsSep = ""
, ppCurrent = xmobarColor cyan "" . clickable wsIconFull
, ppVisible = xmobarColor grey4 "" . clickable wsIconFull
, ppVisibleNoWindows = Just (xmobarColor grey4 "" . clickable wsIconFull)
, ppHidden = xmobarColor grey2 "" . clickable wsIconHidden
, ppHiddenNoWindows = xmobarColor grey2 "" . clickable wsIconEmpty
, ppUrgent = xmobarColor orange "" . clickable wsIconFull
, ppOrder = \(ws : _ : _ : extras) -> ws : extras
, ppExtras = [ wrapL " " " " $ layoutColorIsActive s (logLayoutOnScreen s)
,titleColorIsActive s (shortenL 81 $ logTitleOnScreen s)
]
}
where
wsIconFull = " <fn=2>\xf111</fn> "
wsIconHidden = " <fn=2>\xf111</fn> "
wsIconEmpty = " <fn=2>\xf10c</fn> "
titleColorIsActive n l = do
c <- withWindowSet $ return . W.screen . W.current
if n == c then xmobarColorL cyan "" l else xmobarColorL grey3 "" l
layoutColorIsActive n l = do
c <- withWindowSet $ return . W.screen . W.current
if n == c then wrapL "<icon=/home/afonso/.config/xmobar/xpm/" "_selected.xpm/>" l else wrapL "<icon=/home/afonso/.config/xmobar/xpm/" ".xpm/>" l
\end{code}
\subsection{Config Binding}
\begin{code}
myConfig xmproc = def
myConfig = def
{
terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse,
@ -269,30 +325,14 @@ Percent of screen to increment by when resizing panes
layoutHook = spacingWithEdge 10 $ myLayout,
manageHook = manageSpawn <+> myManageHook <+> manageHook def,
handleEventHook = myEventHook <+> fullscreenEventHook,
startupHook = myStartupHook,
logHook = dynamicLogWithPP $ xmobarPP
{ ppOutput = \x -> hPutStrLn xmproc x -- xmobar on monitor 1
, ppCurrent = xmobarColor color02 "" . wrap
("<box type=Bottom width=2 mb=2 color=" ++ color02 ++ ">") "</box>"
, ppVisible = xmobarColor color05 "" . clickable
, ppHidden = xmobarColor color01 "" . wrap
("<box type=Top width=2 mt=2 color=" ++ color01 ++ ">") "</box>" . clickable
, ppHiddenNoWindows = xmobarColor color01 "" . clickable
, ppTitle = xmobarColor color04 "" . shorten 60
, ppSep = "<fc=" ++ color03 ++ "> <fn=1>|</fn> </fc>"
, ppUrgent = xmobarColor color02 "" . wrap "!" "!"
, ppExtras = [windowCount]
, ppOrder = \(ws:l:t:ex) -> [ws]++ex++[t]
}
}
startupHook = myStartupHook}
\end{code}
\subsection{Main}
\begin{code}
main :: IO ()
main = do
xmproc <- spawnPipe "xmobar -x 0 ~/.config/xmobar/xmobarrc" -- launch on monitor 1
xmonad $ ewmh $ ewmhFullscreen $ docks $ additionalKeysP (removeKeysP (myConfig xmproc) myRemoveKeys) myKeys
xmonad . ewmh . ewmhFullscreen . dynamicSBs myStatusBarSpawner . docks $ additionalKeysP (removeKeysP myConfig myRemoveKeys) myKeys
\end{code}
\subsection{Default Bindings}