diff --git a/home/programs/xmonad/default.nix b/home/programs/xmonad/default.nix index 28cc4a4..e783403 100644 --- a/home/programs/xmonad/default.nix +++ b/home/programs/xmonad/default.nix @@ -12,5 +12,12 @@ }; }; - home.packages = with pkgs; [ xmobar maim xdotool xorg.xmessage ghc ]; + home.packages = with pkgs; [ + xmobar + maim + xdotool + xorg.xmessage + ghc + cabal-install + ]; } diff --git a/home/programs/xmonad/src/xmobar/Plugins/Audio.hs b/home/programs/xmonad/src/xmobar/Plugins/Audio.hs index a1bcd6f..6a8a4c6 100644 --- a/home/programs/xmonad/src/xmobar/Plugins/Audio.hs +++ b/home/programs/xmonad/src/xmobar/Plugins/Audio.hs @@ -1,14 +1,24 @@ module Plugins.Audio where import Xmobar +import Xmobar.Run.Timer (doEveryTenthSeconds) +import System.Process +import System.Exit +import System.IO (hClose, hGetLine) data Audio = Audio String Int deriving (Read, Show) instance Exec Audio where alias (Audio _ _) = "audio" - run (Audio f _) = audio f - rate (Audio _ r) = r + start (Audio f r) cb = if r > 0 then (doEveryTenthSeconds r (audio f cb)) else audio f cb -audio :: String -> IO String -audio format = do - return $ show (format) +audio :: String -> (String -> IO ()) -> IO () +audio format cb = do + (i,o,e,p) <- runInteractiveProcess "pulseaudio-ctl full-status" [] Nothing Nothing + exit <- waitForProcess p + let closeHandles = hClose o >> hClose i >> hClose e + getL = hGetLine o + str <- getL + closeHandles + cb str +--readProcess "pulseaudio-ctl full-status" [] diff --git a/home/programs/xmonad/src/xmobar/cabal.project b/home/programs/xmonad/src/xmobar/cabal.project new file mode 100644 index 0000000..c7ad71d --- /dev/null +++ b/home/programs/xmonad/src/xmobar/cabal.project @@ -0,0 +1,6 @@ +packages: . + +with-compiler: ghc-9.2.4 + +package xmobar + flags: +all_extensions diff --git a/home/programs/xmonad/src/xmobar/xmobar-custom.cabal b/home/programs/xmonad/src/xmobar/xmobar-custom.cabal index bbb66fb..02970c2 100644 --- a/home/programs/xmonad/src/xmobar/xmobar-custom.cabal +++ b/home/programs/xmonad/src/xmobar/xmobar-custom.cabal @@ -44,7 +44,8 @@ executable xmobar -- Other library packages from which modules are imported. build-depends: base ^>=4.17.2.1, - xmobar ^>=0.47.1 + xmobar ^>=0.47.1, + process -- Directories containing source files. hs-source-dirs: .