clunk: make polybar use dynamic hostname

This commit is contained in:
Aaron Bieber 2024-01-24 07:09:34 -07:00
parent ea8deadc45
commit e8ea921321
No known key found for this signature in database
2 changed files with 6 additions and 5 deletions

View File

@ -68,7 +68,7 @@ in
windowManager.xmonad = { windowManager.xmonad = {
enable = true; enable = true;
extraPackages = haskellPackages: [ haskellPackages.xmonad-contrib ]; extraPackages = haskellPackages: with haskellPackages; [ xmonad-contrib hostname ];
config = builtins.readFile ./xmonad.hs; config = builtins.readFile ./xmonad.hs;
}; };
}; };

View File

@ -2,6 +2,7 @@
import qualified Data.Map as M import qualified Data.Map as M
import Data.Monoid import Data.Monoid
import Network.HostName
import XMonad import XMonad
import XMonad.Actions.CycleWS import XMonad.Actions.CycleWS
import XMonad.Hooks.EwmhDesktops import XMonad.Hooks.EwmhDesktops
@ -32,6 +33,7 @@ instance UrgencyHook LibNotifyUrgencyHook where
main :: IO () main :: IO ()
main = do main = do
hostname <- getHostName
xmonad $ xmonad $
ewmh $ ewmh $
withUrgencyHook LibNotifyUrgencyHook $ withUrgencyHook LibNotifyUrgencyHook $
@ -41,7 +43,7 @@ main = do
, focusFollowsMouse = False , focusFollowsMouse = False
, terminal = "alacritty" , terminal = "alacritty"
, workspaces = myWorkspaces , workspaces = myWorkspaces
, startupHook = myStartupHook , startupHook = myStartupHook hostname
, layoutHook = myLayoutHook , layoutHook = myLayoutHook
, keys = \c -> myKeys c `M.union` XMonad.keys def c , keys = \c -> myKeys c `M.union` XMonad.keys def c
, manageHook = manageDocks <+> myManageHook <+> manageHook def , manageHook = manageDocks <+> myManageHook <+> manageHook def
@ -136,6 +138,5 @@ myManageHook =
, className =? "XConsole" --> doF (W.shift (myWorkspaces !! 8)) , className =? "XConsole" --> doF (W.shift (myWorkspaces !! 8))
] ]
myStartupHook :: X () myStartupHook hostname = do
myStartupHook = do spawn ("pkill polybar; polybar " ++ hostname)
spawn "pkill polybar; polybar"