neovim -> coc-nvim
This commit is contained in:
53
home/programs/xmonad/src/xmobar/Plugins/Audio.hs
Normal file
53
home/programs/xmonad/src/xmobar/Plugins/Audio.hs
Normal file
@@ -0,0 +1,53 @@
|
||||
-----------------------------------------------------------------------------
|
||||
-- |
|
||||
-- Module : Plugins.Audio
|
||||
-- Copyright : (c) Elias Schröter
|
||||
-- License : ???
|
||||
--
|
||||
-- Maintainer : Elias Schröter <elias.schroeter@e.email>
|
||||
-- Stability : unstable
|
||||
-- Portability : untested
|
||||
--
|
||||
-- A simple plugin to display the Audio status.
|
||||
--
|
||||
-- This plugin needs 7 parameters : The MuteColor UnMuteColor SpeakerMuteIcon SpeakerIcon MicrophoneMuteIcon MicrophoneIcon and the update rate of the plugin
|
||||
-- in tenth of seconds.
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
module Plugins.Audio where
|
||||
|
||||
import Plugins
|
||||
import System.Process
|
||||
|
||||
-- | Color for Muted
|
||||
type MuteColor = String
|
||||
-- | Color for Unmuted
|
||||
type UnMuteColor = String
|
||||
-- | The Icon of the muted Speaker
|
||||
type SpeakerMuteIcon = String
|
||||
-- | The Icon of the unmuted Speaker
|
||||
type SpeakerIcon = String
|
||||
-- | The Icon of the muted Microphone
|
||||
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)
|
||||
|
||||
-- | Counts the days to a specific date from today. This function returns the number
|
||||
-- of days followed by a String
|
||||
cdw :: Cyear -> Cmonth -> Cday -> String -> IO String
|
||||
cdw y m d s = do currentTime <- getCurrentTime
|
||||
let currentDay = utctDay currentTime
|
||||
let countdownDay = fromGregorian y m d
|
||||
return $ show (diffDays countdownDay currentDay) ++ s
|
||||
|
||||
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]
|
||||
|
||||
instance Exec Countdown where
|
||||
alias ( Audio _ _ _ _ _ _ _) = "audio"
|
||||
run ( Audio mC umC smI sI mmI mI _ ) = getAudio
|
||||
rate ( Countdown _ _ _ _ _ _ r ) = r
|
||||
@@ -1,4 +1,8 @@
|
||||
import Xmobar
|
||||
--import Xmobar.Run.Exec
|
||||
--import Xmobar (Command(ComX))
|
||||
--import GHC.Real (Integral(rem))
|
||||
|
||||
|
||||
config :: Config
|
||||
config =
|
||||
@@ -13,6 +17,35 @@ config =
|
||||
, 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 \"<fc=$SpeakerColor><fn=1>$Symbol</fn></fc> $Volume% <fc=$MicColor><fn=1>$MicOut</fn></fc>\""] "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\";
|
||||
-- else Symbol=\"\xf028\";
|
||||
-- fi;
|
||||
--
|
||||
-- if [[ $Microphone == \"yes\" ]];
|
||||
-- then
|
||||
-- MicOut=\"\xf036d\";
|
||||
-- MicColor=\"#f38ba8\";
|
||||
-- else MicOut=\"\xf036c\";
|
||||
-- fi;
|
||||
--
|
||||
-- echo \"<fc=$SpeakerColor><fn=1>$Symbol</fn></fc> $Volume% <fc=$MicColor><fn=1>$MicOut</fn></fc>\""] "audio" 10
|
||||
--Run $ Audio
|
||||
--[
|
||||
-- "--template", "<fc=<speakerColor>><fn=1><speakerIcon></fn></fc> <Volume>% <fc=<micColor>><fn=1><micIcon></fn></fc>"
|
||||
-- , "" ""
|
||||
--] 10
|
||||
, Run $ Com "/bin/sh" ["-c", "echo \"<fc=#f9e2af><fn=1>\xf00e0</fn></fc> $(xbacklight -get)%\""] "backlight" 10
|
||||
, Run $ Cpu
|
||||
[
|
||||
@@ -65,6 +98,37 @@ config =
|
||||
, template = "%XMonadLog% }{ %audio% | %backlight% | %cpu% | %memory% | %battery% | %dynnetwork% | %date% "
|
||||
}
|
||||
|
||||
--instance Exec Audio where
|
||||
-- alias (Audio _ _ ) = "audio"
|
||||
-- start (Audio a r) = startAudio a r
|
||||
-- where
|
||||
-- startAudio :: [String] -> Int -> (String -> IO ()) -> IO ()
|
||||
-- startAudio =
|
||||
--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\";
|
||||
-- else Symbol=\"\xf028\";
|
||||
-- fi;
|
||||
--
|
||||
-- if [[ $Microphone == \"yes\" ]];
|
||||
-- then
|
||||
-- MicOut=\"\xf036d\";
|
||||
-- MicColor=\"#f38ba8\";
|
||||
-- else MicOut=\"\xf036c\";
|
||||
-- fi;
|
||||
--
|
||||
-- echo \"<fc=$SpeakerColor><fn=1>$Symbol</fn></fc> $Volume% <fc=$MicColor><fn=1>$MicOut</fn></fc>\""] "audio" 10
|
||||
|
||||
main :: IO ()
|
||||
main = xmobar config
|
||||
|
||||
|
||||
Reference in New Issue
Block a user