diff --git a/home/programs/xmonad/src/xmobar/Plugins.hs b/home/programs/xmonad/src/xmobar/Plugins.hs new file mode 100644 index 0000000..4255244 --- /dev/null +++ b/home/programs/xmonad/src/xmobar/Plugins.hs @@ -0,0 +1,25 @@ +----------------------------------------------------------------------------- +-- | +-- Module : Xmobar.Plugins +-- Copyright : (c) Andrea Rossato +-- License : BSD-style (see LICENSE) +-- +-- Maintainer : Jose A. Ortega Ruiz +-- Stability : unstable +-- Portability : unportable +-- +-- This module exports the API for plugins. +-- +-- Have a look at Plugins\/HelloWorld.hs +-- +----------------------------------------------------------------------------- + +module Plugins + ( Exec (..) + , tenthSeconds + , readFileSafe + , hGetLineSafe + ) where + +import Commands +import XUtil diff --git a/home/programs/xmonad/src/xmobar/Plugins/Audio.hs b/home/programs/xmonad/src/xmobar/Plugins/Audio.hs index dfe10bc..e8e5ec5 100644 --- a/home/programs/xmonad/src/xmobar/Plugins/Audio.hs +++ b/home/programs/xmonad/src/xmobar/Plugins/Audio.hs @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------ +-- ----------------------------------------------------------------------------- -- | -- Module : Plugins.Audio -- Copyright : (c) Elias Schröter @@ -16,8 +16,9 @@ module Plugins.Audio where -import Plugins +--import Plugins import System.Process +import GHC.Show (Show(show)) -- | Color for Muted type MuteColor = String @@ -25,6 +26,8 @@ type MuteColor = String type UnMuteColor = String -- | The Icon of the muted Speaker type SpeakerMuteIcon = String +-- | The Icon of half volume Speaker +type SpeakerHalfIcon = String -- | The Icon of the unmuted Speaker type SpeakerIcon = String -- | The Icon of the muted Microphone @@ -32,7 +35,7 @@ type MicrophoneMuteIcon = String -- | The Icon of the unmuted Microphone type MicrophoneIcon = String -data Audio = Audio MuteColor UnMuteColor SpeakerMuteIcon SpeakerIcon MicrophoneMuteIcon MicrophoneIcon Int deriving (Read, Show) +data Audio = Audio MuteColor UnMuteColor SpeakerMuteIcon SpeakerHalfIcon SpeakerIcon MicrophoneMuteIcon MicrophoneIcon Int deriving (Read, Show) -- | Counts the days to a specific date from today. This function returns the number -- of days followed by a String @@ -44,10 +47,10 @@ cdw y m d s = do currentTime <- getCurrentTime getAudio :: MuteColor -> UnMuteColor -> SpeakerMuteIcon -> SpeakerIcon -> MicrophoneMuteIcon -> MicrophoneIcon -> IO String getAudio mC umC smI sI mmI mI = do - let status = readProcess "pulseaudio-ctl full-status" - let infoList = [w | w <- words status] + let status = words readProcess "pulseaudio-ctl full-status" + return $ show status -instance Exec Countdown where - alias ( Audio _ _ _ _ _ _ _) = "audio" - run ( Audio mC umC smI sI mmI mI _ ) = getAudio - rate ( Countdown _ _ _ _ _ _ r ) = r +instance Exec Audio where + alias ( Audio {}) = "audio" + run ( Audio mC umC smI shI sI mmI mI _ ) = getAudio + rate ( Audio _ _ _ _ _ _ _ r ) = r diff --git a/home/programs/xmonad/src/xmobar/xmobar-custom.cabal b/home/programs/xmonad/src/xmobar/xmobar-custom.cabal index 26a1c2e..9547c55 100644 --- a/home/programs/xmonad/src/xmobar/xmobar-custom.cabal +++ b/home/programs/xmonad/src/xmobar/xmobar-custom.cabal @@ -23,10 +23,10 @@ name: xmobar-custom version: 0.1.0.0 -- The package author(s). -author: einfischy +author: 4Lost -- An email address to which users can send suggestions, bug reports, and patches. -maintainer: accounts.codeberg@kstn.in +maintainer: elias.schroeter@e.email -- A copyright notice. -- copyright: @@ -42,9 +42,11 @@ executable xmobar -- .hs or .lhs file containing the Main module. main-is: xmobar.hs + other-modules: Plugins.Audio -- Other library packages from which modules are imported. build-depends: base ^>=4.17.2.1, - xmobar ^>=0.47.1 + xmobar ^>=0.47.1, + process ^>=1.6.18.0 -- Directories containing source files. hs-source-dirs: . diff --git a/home/programs/xmonad/src/xmobar/xmobar.hs b/home/programs/xmonad/src/xmobar/xmobar.hs index e10bba5..1e97f30 100644 --- a/home/programs/xmonad/src/xmobar/xmobar.hs +++ b/home/programs/xmonad/src/xmobar/xmobar.hs @@ -1,4 +1,5 @@ import Xmobar +import Plugins.Audio --import Xmobar.Run.Exec --import Xmobar (Command(ComX)) --import GHC.Real (Integral(rem)) @@ -16,7 +17,7 @@ config = , fgColor = "#f5e0dc" , commands = [ - Run $ Com "/bin/sh" ["-c", "Status=$(pulseaudio-ctl full-status); Volume=$(cut -d ' ' -f 1 <<<$Status); Mute=$(cut -d ' ' -f 2 <<<$Status); Microphone=$(cut -d ' ' -f 3 <<<$Status); SpeakerColor=\"#a6e3a1\"; MicColor=\"#a6e3a1\"; if [[ $Mute == \"yes\" ]]; then Symbol=\"\xf466\"; SpeakerColor=\"#f38ba8\"; elif [[ $Volume -le 50 ]]; then Symbol=\"\xf027\"; elseSymbol=\"\xf028\"; fi; if [[ $Microphone == \"yes\" ]]; then MicOut=\"\xf036d\"; MicColor=\"#f38ba8\"; else MicOut=\"\xf036c\"; fi; echo \"$Symbol $Volume% $MicOut\""] "audio" 10 + --Run $ Com "/bin/sh" ["-c", "Status=$(pulseaudio-ctl full-status); Volume=$(cut -d ' ' -f 1 <<<$Status); Mute=$(cut -d ' ' -f 2 <<<$Status); Microphone=$(cut -d ' ' -f 3 <<<$Status); SpeakerColor=\"#a6e3a1\"; MicColor=\"#a6e3a1\"; if [[ $Mute == \"yes\" ]]; then Symbol=\"\xf466\"; SpeakerColor=\"#f38ba8\"; elif [[ $Volume -le 50 ]]; then Symbol=\"\xf027\"; elseSymbol=\"\xf028\"; fi; if [[ $Microphone == \"yes\" ]]; then MicOut=\"\xf036d\"; MicColor=\"#f38ba8\"; else MicOut=\"\xf036c\"; fi; echo \"$Symbol $Volume% $MicOut\""] "audio" 10 --Run $ Com "/bin/sh" ["-c", "Status=$(pulseaudio-ctl full-status); -- Volume=$(cut -d ' ' -f 1 <<<$Status); -- Mute=$(cut -d ' ' -f 2 <<<$Status); @@ -46,6 +47,7 @@ config = -- "--template", "> % >" -- , "" "" --] 10 + Run $ Audio "#f38ba8" "#a6e3a1" "\xf466" "\xf027" "\xf027" "\xf036d" "\xf036c" 10 , Run $ Com "/bin/sh" ["-c", "echo \"\xf00e0 $(xbacklight -get)%\""] "backlight" 10 , Run $ Cpu [