ktouch & discord

This commit is contained in:
2024-03-19 17:47:55 +01:00
parent 832448b0e0
commit d51ea215f8
9 changed files with 65 additions and 42 deletions

View File

@@ -17,7 +17,7 @@ in {
import = "${theme}"; import = "${theme}";
}; };
font = { font = {
size = 9; size = 7;
normal.family = "Fira Code"; normal.family = "Fira Code";
bold.family = "Fira Code"; bold.family = "Fira Code";
italic.family = "Fira Code"; italic.family = "Fira Code";

View File

@@ -2,8 +2,10 @@
imports = [ imports = [
./alacritty ./alacritty
./anki.nix ./anki.nix
./discord.nix
./element.nix ./element.nix
./git.nix ./git.nix
./ktouch.nix
./neovim ./neovim
./obs ./obs
./planify.nix ./planify.nix

View File

@@ -0,0 +1,5 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [ discord ];
}

5
home/programs/ktouch.nix Normal file
View File

@@ -0,0 +1,5 @@
{ pkgs, ... }:
{
home.programs = with pkgs.libsForQt5; [ ktouch ];
}

View File

@@ -1,8 +1,15 @@
{
"languageserver": { "languageserver": {
"haskell": { "haskell": {
"command": "haskell-language-server-wrapper", "command": "haskell-language-server-wrapper",
"args": ["--lsp"], "args": ["--lsp"],
"rootPatterns": ["*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml"], "rootPatterns": [
"*.cabal",
"stack.yaml",
"cabal.project",
"package.yaml",
"hie.yaml"
],
"filetypes": ["haskell", "lhaskell"], "filetypes": ["haskell", "lhaskell"],
// Settings are optional, here are some example values // Settings are optional, here are some example values
"settings": { "settings": {
@@ -18,3 +25,4 @@
} }
} }
} }
}

View File

@@ -1,24 +1,33 @@
module Plugins.Audio where module Plugins.Audio where
import Xmobar import Xmobar
import Xmobar.Run.Timer (doEveryTenthSeconds)
import System.Process import System.Process
import System.Exit import Control.Concurrent
import System.IO (hClose, hGetLine)
data Audio = Audio String Int deriving (Read, Show) data Audio = Audio Int deriving (Read, Show)
instance Exec Audio where instance Exec Audio where
alias (Audio _ _) = "audio" alias (Audio _) = "audio"
start (Audio f r) cb = if r > 0 then (doEveryTenthSeconds r (audio f cb)) else audio f cb start (Audio r) cb = if r > 0 then go cb r else go cb 1000
where
go :: (String -> IO ()) -> Int -> IO ()
go cb r = do
response <- readProcess "/bin/sh" ["-c", "pulseaudio-ctl full-status"] ""
let list = [w | w <- words (init response)]
audio (head list) (list !! 1) (last list) cb
threadDelay r
go cb r
audio :: String -> (String -> IO ()) -> IO () audio :: String -> String -> String -> (String -> IO ()) -> IO ()
audio format cb = do audio vol speaker mic cb
(i,o,e,p) <- runInteractiveProcess "pulseaudio-ctl full-status" [] Nothing Nothing | speaker == "yes" = chooseMic vol "#f38ba8" "\xf466" mic cb
exit <- waitForProcess p | elem vol [show i | i <- [0..49]] = chooseMic vol "#a6e3a1" "\xf027" mic cb
let closeHandles = hClose o >> hClose i >> hClose e | otherwise = chooseMic vol "#a6e3a1" "\xf028" mic cb
getL = hGetLine o | otherwise = formatAudio vol "a" "c" "d" "e" cb
str <- getL where
closeHandles chooseMic :: String -> String -> String -> String -> (String -> IO ()) -> IO ()
cb str chooseMic vol speakerC speakerI mic cb
--readProcess "pulseaudio-ctl full-status" [] | mic == "yes" = formatAudio vol speakerC speakerI "#f38ba8" "\xf036d" cb
| otherwise = formatAudio vol speakerC speakerI "#a6e3a1" "\xf036c" cb
formatAudio :: String -> String -> String -> String -> String -> (String -> IO ()) -> IO ()
formatAudio vol speakerC speakerI micC micI cb = cb ("<fc=" ++ speakerC ++ "><fn=1>" ++ speakerI ++ "</fn></fc> " ++ vol ++ "% <fc=" ++ micC ++ "><fn=1>" ++ micI ++ "</fn></fc>")

View File

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

View File

@@ -17,8 +17,8 @@ config =
, fgColor = "#f5e0dc" , fgColor = "#f5e0dc"
, commands = , commands =
[ [
Run $ Audio "abc" 200 --Run $ 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 \"<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\"; 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" 60
--Run $ Com "/bin/sh" ["-c", "Status=$(pulseaudio-ctl full-status); --Run $ Com "/bin/sh" ["-c", "Status=$(pulseaudio-ctl full-status);
-- Volume=$(cut -d ' ' -f 1 <<<$Status); -- Volume=$(cut -d ' ' -f 1 <<<$Status);
-- Mute=$(cut -d ' ' -f 2 <<<$Status); -- Mute=$(cut -d ' ' -f 2 <<<$Status);
@@ -40,7 +40,7 @@ config =
-- MicOut=\"\xf036d\"; -- MicOut=\"\xf036d\";
-- MicColor=\"#f38ba8\"; -- MicColor=\"#f38ba8\";
-- else MicOut=\"\xf036c\"; -- else MicOut=\"\xf036c\";
-- fi; -- fi;xmobar.Run not found
-- --
-- echo \"<fc=$SpeakerColor><fn=1>$Symbol</fn></fc> $Volume% <fc=$MicColor><fn=1>$MicOut</fn></fc>\""] "audio" 10 -- echo \"<fc=$SpeakerColor><fn=1>$Symbol</fn></fc> $Volume% <fc=$MicColor><fn=1>$MicOut</fn></fc>\""] "audio" 10
--Run $ Audio --Run $ Audio

View File

@@ -54,7 +54,7 @@ myconfig = def
, ("<XF86AudioLowerVolume>", spawn "pulseaudio-ctl down 5") , ("<XF86AudioLowerVolume>", spawn "pulseaudio-ctl down 5")
, ("<XF86AudioMicMute>", spawn "pulseaudio-ctl mute-input") , ("<XF86AudioMicMute>", spawn "pulseaudio-ctl mute-input")
] ]
`removeKeysP` [] `removeKeysP` [ "M-S-q" ]
myXmobarPP :: PP myXmobarPP :: PP
myXmobarPP = def myXmobarPP = def