updated xmonad to use custom pactl scripts to controll volume, also updated xinit rc so that the xrandr section only happens on the laptop.

This commit is contained in:
Solomon Laing 2021-03-23 19:04:43 +10:30
parent 892be92c28
commit 16f41bd04a
6 changed files with 57 additions and 7 deletions

11
.scripts/dec-default-volume Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
default_loc=/tmp/pactl-default-source
if [ ! -f "$default_loc" ] ; then
/home/solomon/.scripts/set-default-card
fi
default=$(cat $default_loc)
pactl set-sink-volume $default -5%

11
.scripts/inc-default-volume Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
default_loc=/tmp/pactl-default-source
if [ ! -f "$default_loc" ] ; then
/home/solomon/.scripts/set-default-card
fi
default=$(cat $default_loc)
pactl set-sink-volume $default +5%

6
.scripts/set-sound-card Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
choice=$(pactl list short sinks | awk '{print $2}' | dmenu -i -p "which source should be default?")
rm /tmp/pactl-default-source --force # to ignore if it isn't there
echo "$choice" >> /tmp/pactl-default-source

11
.scripts/toggle-default-mute Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
default_loc=/tmp/pactl-default-source
if [ ! -f "$default_loc" ] ; then
/home/solomon/.scripts/set-default-card
fi
default=$(cat $default_loc)
pactl set-sink-mute $default toggle

View File

@ -39,8 +39,13 @@ fi
# nividia config, note that nvidia and nvidia-prime were needed
# it seems modules and xorg confs were not due to there being an intel
# integrated card, not sure how the desktop will react though
HOST=$(cat /etc/hostname)
if [ "$HOST" == "archmetabox" ] ; then
# this is specifically for the laptop so check hostname
xrandr --setprovideroutputsource modesetting NVIDIA-G0
xrandr --auto
fi
# start my trusty window manager
xmonad &

View File

@ -112,6 +112,7 @@ myModMask = mod4Mask
-- The default number of workspaces (virtual screens) and their names.
-- By default we use numeric strings, but any string may be used as a
-- workspace name. The number of workspaces is determined by the length
-- of this list.
--
-- A tagging example:
@ -234,13 +235,16 @@ myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
--
[
-- decrease volume with mod+f11
((modm, xK_F11), spawn "pactl set-sink-volume 0 -5%")
((modm, xK_F11), spawn "/home/solomon/.scripts/dec-default-volume")
-- increase volume with mod+f12
,((modm, xK_F12), spawn "pactl set-sink-volume 0 +5%")
,((modm, xK_F12), spawn "/home/solomon/.scripts/inc-default-volume")
-- toggle mute with mod+f10
,((modm, xK_F10), spawn "pactl set-sink-mute 0 toggle")
,((modm, xK_F10), spawn "/home/solomon/.scripts/toggle-default-mute")
-- set default sink for pactl to allow above scripts to run
,((modm .|. shiftMask, xK_F10), spawn "/home/solomon/.scripts/set-sound-card")
]
++
@ -436,7 +440,6 @@ myStartupHook = do
-- Startup apps (tray) and settings
spawnOnce "/home/solomon/.screenlayout/normal.sh" -- really only matters for desktop
spawnOnce "trayer --edge top --align right --widthtype request --padding 6 --SetDockType true --SetPartialStrut true --expand true --monitor 1 --transparent true --alpha 0 --tint 0x14071F --height 20 &"
spawnOnce "volumeicon &"
spawnOnce "nm-applet &"
spawnOnce "blueman-applet &"
@ -450,6 +453,9 @@ myStartupHook = do
spawnOnce "slack &"
spawnOnce "todoist &"
-- Start trayer last
spawnOnce "trayer --edge top --align right --widthtype request --padding 6 --SetDockType true --SetPartialStrut true --expand true --monitor 1 --transparent true --alpha 0 --tint 0x14071F --height 20 &"
------------------------------------------------------------------------
-- Now run xmonad with all the defaults we set up.