xmobar -> own Module 2

This commit is contained in:
2024-03-18 22:21:19 +01:00
parent 412a3a6526
commit 832448b0e0
4 changed files with 31 additions and 7 deletions

View File

@@ -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
];
}

View File

@@ -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" []

View File

@@ -0,0 +1,6 @@
packages: .
with-compiler: ghc-9.2.4
package xmobar
flags: +all_extensions

View File

@@ -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: .