From 16f41bd04a9c2785d04556466c567b5456dfcbcb Mon Sep 17 00:00:00 2001 From: Solomon Laing Date: Tue, 23 Mar 2021 19:04:43 +1030 Subject: [PATCH] updated xmonad to use custom pactl scripts to controll volume, also updated xinit rc so that the xrandr section only happens on the laptop. --- .scripts/dec-default-volume | 11 +++++++++++ .scripts/inc-default-volume | 11 +++++++++++ .scripts/set-sound-card | 6 ++++++ .scripts/toggle-default-mute | 11 +++++++++++ .xinitrc | 9 +++++++-- .xmonad/xmonad.hs | 16 +++++++++++----- 6 files changed, 57 insertions(+), 7 deletions(-) create mode 100755 .scripts/dec-default-volume create mode 100755 .scripts/inc-default-volume create mode 100755 .scripts/set-sound-card create mode 100755 .scripts/toggle-default-mute diff --git a/.scripts/dec-default-volume b/.scripts/dec-default-volume new file mode 100755 index 0000000..2fe400f --- /dev/null +++ b/.scripts/dec-default-volume @@ -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% diff --git a/.scripts/inc-default-volume b/.scripts/inc-default-volume new file mode 100755 index 0000000..96548f7 --- /dev/null +++ b/.scripts/inc-default-volume @@ -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% diff --git a/.scripts/set-sound-card b/.scripts/set-sound-card new file mode 100755 index 0000000..1c36ed8 --- /dev/null +++ b/.scripts/set-sound-card @@ -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 \ No newline at end of file diff --git a/.scripts/toggle-default-mute b/.scripts/toggle-default-mute new file mode 100755 index 0000000..08c1477 --- /dev/null +++ b/.scripts/toggle-default-mute @@ -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 diff --git a/.xinitrc b/.xinitrc index 1ff7fc2..4301932 100644 --- a/.xinitrc +++ b/.xinitrc @@ -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 -xrandr --setprovideroutputsource modesetting NVIDIA-G0 -xrandr --auto + +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 & diff --git a/.xmonad/xmonad.hs b/.xmonad/xmonad.hs index 678ed5b..1cf0fb4 100644 --- a/.xmonad/xmonad.hs +++ b/.xmonad/xmonad.hs @@ -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") + -- toggle mute with mod+f10 + ,((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.