graphical: set volume settings via window manager

sound.mediaKeys doesn't work with pulseaudio enabled, but some programs
e.g. Firefox require it.
This commit is contained in:
Timothy DeHerrera 2020-06-25 21:54:34 -06:00
parent 51ef800af6
commit 77a635348f
No known key found for this signature in database
GPG Key ID: 8985725DB5B0C122
5 changed files with 19 additions and 10 deletions

View File

@ -5,7 +5,7 @@ in {
hardware.opengl.enable = true;
hardware.opengl.driSupport = true;
hardware.pulseaudio.enable = false;
hardware.pulseaudio.enable = true;
environment = {
etc = {
@ -37,6 +37,7 @@ in {
};
systemPackages = with pkgs; [
pulsemixer
adapta-gtk-theme
cursor
dzen2

View File

@ -96,9 +96,9 @@ for_window [app_id=".*"] inhibit_idle fullscreen
bindsym $mod+f fullscreen
# display volume level when pushed
bindsym XF86AudioRaiseVolume exec $volume
bindsym XF86AudioLowerVolume exec $volume
bindsym XF86AudioMute exec $volume
bindsym XF86AudioRaiseVolume exec $volume; $mixer 2%+ unmute
bindsym XF86AudioLowerVolume exec $volume; $mixer 2%- unmute
bindsym XF86AudioMute exec $volume; $mixer toggle
# Drag floating windows by holding down $mod and left mouse button.
# Resize them with right mouse button + $mod.

View File

@ -40,6 +40,7 @@ in {
let volnoti = import ../misc/volnoti.nix { inherit pkgs; };
in ''
set $volume ${volnoti}
set $mixer "${pkgs.alsaUtils}/bin/amixer -q set Master"
# set background
output * bg ${pkgs.adapta-backgrounds}/share/backgrounds/adapta/tri-fadeno.jpg fill

View File

@ -1,4 +1,6 @@
{ autostart, screenshots, touchtoggle, pkgs, stoggle, volnoti }: ''
{ autostart, screenshots, touchtoggle, pkgs, stoggle, volnoti }:
let inherit (pkgs) alsaUtils;
in ''
-- Function for fullscreen toggle
fullToggle :: X ()
fullToggle = do
@ -6,6 +8,11 @@
sendMessage $ Toggle NBFULL
sendMessage $ SetStruts [] [minBound .. maxBound]
setVolume :: String -> X ()
setVolume options = do
spawn ("${alsaUtils}/bin/amixer -q set Master " ++ options)
spawn "${volnoti}"
myAutostart :: X ()
myAutostart = do
spawn "${autostart}"
@ -41,15 +48,15 @@
)
-- lower volume
, ( ( 0 , xF86XK_AudioLowerVolume )
, spawn "${volnoti}"
, setVolume "2%- unmute"
)
-- raise volume
, ( ( 0 , xF86XK_AudioRaiseVolume )
, spawn "${volnoti}"
, setVolume "2%+ unmute"
)
-- mute volume
, ( ( 0 , xF86XK_AudioMute )
, spawn "${volnoti}"
, setVolume "toggle"
)
-- start qutebrowser
, ( ( myModKey , xK_b )

View File

@ -1,4 +1,4 @@
{ pkgs, ... }: {
{ config, pkgs, lib, ... }: {
environment.systemPackages = with pkgs; [
acpi
lm_sensors
@ -27,7 +27,7 @@
];
};
sound.mediaKeys = {
sound.mediaKeys = lib.mkIf (!config.hardware.pulseaudio.enable) {
enable = true;
volumeStep = "1dB";
};