feat(prog/xmonad): add control for volume

feat(prog/xmobar): show volume
This commit is contained in:
Dmitriy Pleshevskiy 2022-04-12 19:13:35 +03:00
parent 74f7e461c9
commit d6857d4cd5
3 changed files with 87 additions and 75 deletions

View file

@ -0,0 +1,3 @@
#!/bin/bash
echo $(amixer -D pulse sget Master | egrep -o "[0-9]+%" | head -n 1)
exit 0

View file

@ -52,7 +52,7 @@ config n = defaultConfig
, alignSep = "}{" , alignSep = "}{"
, template = "%XMonadLog%" , template = "%XMonadLog%"
<> "} %date% <hspace=60/> %cpu% | %memory% * %swap% | %wlxd03745e1e87bwi%" <> "} %date% <hspace=60/> %cpu% | %memory% * %swap% | %wlxd03745e1e87bwi%"
<> "{ <fn=1><box> %kbd% </box> <fc=#ee9a00>%time%</fc></fn>" <> "{ Vol: %volume% <fn=1><box> %kbd% </box> <fc=#ee9a00>%time%</fc></fn>"
} }
myCommands :: [Runnable] myCommands :: [Runnable]
@ -73,7 +73,6 @@ myCommands =
, Run $ Date "%a %d %b %Y" "date" (10 `seconds`) , Run $ Date "%a %d %b %Y" "date" (10 `seconds`)
, Run $ Date "%H:%M:%S" "time" (1 `seconds`) , Run $ Date "%H:%M:%S" "time" (1 `seconds`)
, Run $ Kbd [("us(dvorak)", "us"), ("ru", "ru")] , Run $ Kbd [("us(dvorak)", "us"), ("ru", "ru")]
, Run $ XMonadLog
, Run $ , Run $
Wireless Wireless
"wlxd03745e1e87b" "wlxd03745e1e87b"
@ -86,6 +85,8 @@ myCommands =
, "--high" , colorGreen , "--high" , colorGreen
] ]
(10 `seconds`) (10 `seconds`)
, Run $ Com "/bin/bash" ["-c", "~/.config/xmobar/scripts/get_volume.sh"] "volume" 1
, Run XMonadLog
] ]
where where
seconds, minutes :: Int -> Int seconds, minutes :: Int -> Int

View file

@ -66,96 +66,100 @@ myFocusedBorderColor = "#f00"
-- --
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
-- launch a terminal -- launch a terminal
[ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
-- launch a 'flameshot' to screenshot -- launch a 'flameshot' to screenshot
, ((modm .|. shiftMask, xK_s ), safeSpawn "flameshot" ["gui"]) , ((modm .|. shiftMask, xK_s ), safeSpawn "flameshot" ["gui"])
-- launch 'dmenu_run' to choose applications -- launch 'dmenu_run' to choose applications
, ((modm, xK_p ), spawn "dmenu_run") , ((modm, xK_p ), spawn "dmenu_run")
-- close focused window -- close focused window
, ((modm .|. shiftMask, xK_c ), kill) , ((modm .|. shiftMask, xK_c ), kill)
-- Rotate through the available layout algorithms -- Rotate through the available layout algorithms
, ((modm, xK_space ), sendMessage NextLayout) , ((modm, xK_space ), sendMessage NextLayout)
-- Reset the layouts on the current workspace to default -- Reset the layouts on the current workspace to default
, ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
-- Resize viewed windows to the correct size -- Resize viewed windows to the correct size
, ((modm, xK_n ), refresh) , ((modm, xK_n ), refresh)
-- Move focus to the next window -- Move focus to the next window
, ((modm, xK_j ), windows W.focusDown) , ((modm, xK_j ), windows W.focusDown)
-- Move focus to the previous window -- Move focus to the previous window
, ((modm, xK_k ), windows W.focusUp) , ((modm, xK_k ), windows W.focusUp)
-- Move focus to the master window -- Move focus to the master window
, ((modm, xK_m ), windows W.focusMaster) , ((modm, xK_m ), windows W.focusMaster)
-- Swap the focused window and the master window -- Swap the focused window and the master window
, ((modm, xK_Return), windows W.swapMaster) , ((modm, xK_Return), windows W.swapMaster)
-- Swap the focused window with the next window -- Swap the focused window with the next window
, ((modm .|. shiftMask, xK_j ), windows W.swapDown) , ((modm .|. shiftMask, xK_j ), windows W.swapDown)
-- Swap the focused window with the previous window -- Swap the focused window with the previous window
, ((modm .|. shiftMask, xK_k ), windows W.swapUp) , ((modm .|. shiftMask, xK_k ), windows W.swapUp)
-- Shrink the master area -- Shrink the master area
, ((modm, xK_h ), sendMessage Shrink) , ((modm, xK_h ), sendMessage Shrink)
-- Expand the master area -- Expand the master area
, ((modm, xK_l ), sendMessage Expand) , ((modm, xK_l ), sendMessage Expand)
-- Push window back into tiling -- Push window back into tiling
, ((modm, xK_t ), withFocused $ windows . W.sink) , ((modm, xK_t ), withFocused $ windows . W.sink)
-- Increment the number of windows in the master area -- Increment the number of windows in the master area
, ((modm , xK_comma ), sendMessage $ IncMasterN 1) , ((modm , xK_comma ), sendMessage $ IncMasterN 1)
-- Deincrement the number of windows in the master area -- Deincrement the number of windows in the master area
, ((modm , xK_period), sendMessage $ IncMasterN (-1)) , ((modm , xK_period), sendMessage $ IncMasterN (-1))
-- Toggle the status bar gap -- Toggle the status bar gap
-- Use this binding with avoidStruts from Hooks.ManageDocks. -- Use this binding with avoidStruts from Hooks.ManageDocks.
-- See also the statusBar function from Hooks.DynamicLog. -- See also the statusBar function from Hooks.DynamicLog.
-- --
-- , ((modm , xK_b ), sendMessage ToggleStruts) -- , ((modm , xK_b ), sendMessage ToggleStruts)
-- Quit xmonad -- Quit xmonad
, ((mod4Mask .|. shiftMask, xK_q ), io exitSuccess) , ((mod4Mask .|. shiftMask, xK_q ), io exitSuccess)
-- Lock screen -- Lock screen
, ((mod4Mask , xK_l ), spawn "i3lock -e -c 000000") , ((mod4Mask , xK_l ), spawn "i3lock -e -c 000000")
-- Restart xmonad -- Change volume
, ((modm , xK_q ), spawn "xmonad --recompile; xmonad --restart") , ((mod4Mask , xK_Up ), spawn "amixer -D pulse sset Master 1%+")
, ((mod4Mask , xK_Down), spawn "amixer -D pulse sset Master 1%-")
-- Run xmessage with a summary of the default keybindings (useful for beginners) -- Restart xmonad
, ((modm .|. shiftMask, xK_slash ), xmessage help) , ((modm , xK_q ), spawn "xmonad --recompile; xmonad --restart")
] -- Run xmessage with a summary of the default keybindings (useful for beginners)
++ , ((modm .|. shiftMask, xK_slash ), xmessage help)
-- ]
-- mod-[1..9], Switch to workspace N ++
-- mod-shift-[1..9], Move client to workspace N
--
[((m .|. modm, k), windows $ f i)
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
++
-- --
-- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3 -- mod-[1..9], Switch to workspace N
-- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3 -- mod-shift-[1..9], Move client to workspace N
-- --
[((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f)) [((m .|. modm, k), windows $ f i)
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..] | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
++
--
-- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
-- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
--
[((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -215,13 +219,13 @@ myLayout = avoidStruts
-- 'className' and 'resource' are used below. -- 'className' and 'resource' are used below.
-- --
myManageHook = composeAll myManageHook = composeAll
[ className =? "MPlayer" --> doFloat [ className =? "MPlayer" --> doFloat
, className =? "Gimp" --> doFloat , className =? "Gimp" --> doFloat
, resource =? "desktop_window" --> doIgnore , resource =? "desktop_window" --> doIgnore
, resource =? "kdesktop" --> doIgnore , resource =? "kdesktop" --> doIgnore
-- my libs -- my libs
, resource =? "hwt" --> doFloat , resource =? "hwt" --> doFloat
] ]
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Event handling -- Event handling
@ -335,4 +339,8 @@ help = unlines
, "mod-button1 Set the window to floating mode and move by dragging" , "mod-button1 Set the window to floating mode and move by dragging"
, "mod-button2 Raise the window to the top of the stack" , "mod-button2 Raise the window to the top of the stack"
, "mod-button3 Set the window to floating mode and resize by dragging" , "mod-button3 Set the window to floating mode and resize by dragging"
, ""
, "-- Volume"
, "mod4-Up Increase volume by 1%"
, "mod4-Down Decrease volume by 1%"
] ]