summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2015-11-25 01:51:35 +0100
committertv <tv@krebsco.de>2015-11-25 01:51:35 +0100
commitf6cca2cdd06d5d65fdb4b08bfceff7a36403f678 (patch)
tree941546c6c5eb2dc46fa79433cb6990b142df93f1
parent3bc83b484ca797c48007fa37d5598f3c59c7da19 (diff)
tv: UNIX domain socket based pulseaudio with XMonad controls
-rw-r--r--tv/1systems/wu.nix2
-rw-r--r--tv/1systems/xu.nix2
-rw-r--r--tv/2configs/pulse.nix83
-rw-r--r--tv/2configs/xserver/default.nix2
-rw-r--r--tv/5pkgs/xmonad-tv/Main.hs4
-rw-r--r--tv/5pkgs/xmonad-tv/xmonad.cabal1
6 files changed, 92 insertions, 2 deletions
diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix
index 3fa5481..cd31397 100644
--- a/tv/1systems/wu.nix
+++ b/tv/1systems/wu.nix
@@ -10,6 +10,7 @@ with lib;
#../2configs/consul-client.nix
../2configs/git.nix
../2configs/mail-client.nix
+ ../2configs/pulse.nix
../2configs/xserver
{
environment.systemPackages = with pkgs; [
@@ -193,7 +194,6 @@ with lib;
hardware.bumblebee.group = "video";
hardware.enableAllFirmware = true;
hardware.opengl.driSupport32Bit = true;
- hardware.pulseaudio.enable = true;
environment.systemPackages = with pkgs; [
xlibs.fontschumachermisc
diff --git a/tv/1systems/xu.nix b/tv/1systems/xu.nix
index 94656ab..eac36fa 100644
--- a/tv/1systems/xu.nix
+++ b/tv/1systems/xu.nix
@@ -13,6 +13,7 @@ with lib;
#../2configs/consul-client.nix
../2configs/git.nix
../2configs/mail-client.nix
+ ../2configs/pulse.nix
../2configs/xserver
{
environment.systemPackages = with pkgs; [
@@ -195,7 +196,6 @@ with lib;
#hardware.bumblebee.group = "video";
hardware.enableAllFirmware = true;
#hardware.opengl.driSupport32Bit = true;
- hardware.pulseaudio.enable = true;
environment.systemPackages = with pkgs; [
#xlibs.fontschumachermisc
diff --git a/tv/2configs/pulse.nix b/tv/2configs/pulse.nix
new file mode 100644
index 0000000..0ddc527
--- /dev/null
+++ b/tv/2configs/pulse.nix
@@ -0,0 +1,83 @@
+{ config, lib, pkgs, ... }:
+
+let
+ pkg = pkgs.pulseaudioLight;
+ runDir = "/run/pulse";
+
+ alsaConf = pkgs.writeText "asound.conf" ''
+ ctl_type.pulse {
+ libs.native = ${pkgs.alsaPlugins}/lib/alsa-lib/libasound_module_ctl_pulse.so;
+ }
+ pcm_type.pulse {
+ libs.native = ${pkgs.alsaPlugins}/lib/alsa-lib/libasound_module_pcm_pulse.so;
+ }
+ ctl.!default {
+ type pulse
+ }
+ pcm.!default {
+ type pulse
+ }
+ '';
+
+ clientConf = pkgs.writeText "client.conf" ''
+ autospawn=no
+ default-server = unix:${runDir}/socket
+ '';
+
+ configFile = pkgs.writeText "default.pa" ''
+ .include ${pkg}/etc/pulse/default.pa
+ load-module ${toString [
+ "module-native-protocol-unix"
+ "auth-anonymous=1"
+ "socket=${runDir}/socket"
+ ]}
+ '';
+in
+
+{
+ systemd.tmpfiles.rules = [
+ "d ${runDir} 0750 pulse pulse - -"
+ "d ${runDir}/home 0700 pulse pulse - -"
+ ];
+
+ system.activationScripts.pulseaudio-hack = ''
+ ln -fns ${clientConf} /etc/pulse/client.conf
+ '';
+
+ environment = {
+ etc = {
+ "asound.conf".source = alsaConf;
+ #"pulse/client.conf" = lib.mkForce { source = clientConf; };
+ "pulse/default.pa".source = configFile;
+ };
+ systemPackages = [ pkg ];
+ };
+
+ # Allow PulseAudio to get realtime priority using rtkit.
+ security.rtkit.enable = true;
+
+ systemd.services.pulse = {
+ wantedBy = [ "sound.target" ];
+ before = [ "sound.target" ];
+ environment = {
+ PULSE_RUNTIME_PATH = "${runDir}/home";
+ #DISPLAY = ":${toString config.services.xserver.display}";
+ };
+ serviceConfig = {
+ ExecStart = "${pkg}/bin/pulseaudio";
+ User = "pulse";
+ };
+ };
+
+ users = let
+ id = 3768151709; # genid pulse
+ in {
+ groups.pulse.gid = id;
+ users.pulse = {
+ uid = id;
+ group = "pulse";
+ extraGroups = [ "audio" ];
+ home = "${runDir}/home";
+ };
+ };
+}
diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix
index afc2d69..f56da7d 100644
--- a/tv/2configs/xserver/default.nix
+++ b/tv/2configs/xserver/default.nix
@@ -101,6 +101,8 @@ let
#! ${pkgs.bash}/bin/bash
set -efu
export PATH; PATH=${makeSearchPath "bin" [
+ # TODO put paths into a Haskell module instead of PATH
+ pkgs.alsaUtils
pkgs.rxvt_unicode
]}:/var/setuid-wrappers
settle() {(
diff --git a/tv/5pkgs/xmonad-tv/Main.hs b/tv/5pkgs/xmonad-tv/Main.hs
index 2258b34..6482d9c 100644
--- a/tv/5pkgs/xmonad-tv/Main.hs
+++ b/tv/5pkgs/xmonad-tv/Main.hs
@@ -7,6 +7,7 @@
module Main where
import Control.Exception
+import Graphics.X11.ExtraTypes.XF86
import Text.Read (readEither)
import XMonad
import System.IO (hPutStrLn, stderr)
@@ -187,6 +188,9 @@ myKeys conf = Map.fromList $
--, (_4 , xK_v ) & \k -> (k, gridselectWorkspace wsGSConfig { gs_navigate = makeGSNav k } W.view)
--, (_4S , xK_v ) & \k -> (k, gridselectWorkspace wsGSConfig { gs_navigate = makeGSNav k } W.shift)
--, (_4 , xK_b ) & \k -> (k, goToSelected wGSConfig { gs_navigate = makeGSNav k })
+ , ((noModMask, xF86XK_AudioLowerVolume), spawn "amixer sset Master 5%-")
+ , ((noModMask, xF86XK_AudioRaiseVolume), spawn "amixer sset Master 5%+")
+ , ((noModMask, xF86XK_AudioMute), spawn "amixer sset Master toggle")
]
where
_4 = mod4Mask
diff --git a/tv/5pkgs/xmonad-tv/xmonad.cabal b/tv/5pkgs/xmonad-tv/xmonad.cabal
index 2246524..f9ea4dd 100644
--- a/tv/5pkgs/xmonad-tv/xmonad.cabal
+++ b/tv/5pkgs/xmonad-tv/xmonad.cabal
@@ -10,6 +10,7 @@ Executable xmonad
base,
containers,
unix,
+ X11,
xmonad,
xmonad-contrib,
xmonad-stockholm