diff --git a/playbooks/home.yml b/playbooks/home.yml index 339bc2e..7952510 100644 --- a/playbooks/home.yml +++ b/playbooks/home.yml @@ -40,6 +40,8 @@ 38306234316364306134396138376230626630633733306432626637616239373838646433343761 3436643661633766616564663937346232353666386531363438 tags: [ desktop ] + - role: pulseaudio + tags: [ pulse, pulseaudio ] - role: desktop-sddm vars: sddm_theme_name: "breeze" diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 979a085..3187c55 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -33,6 +33,7 @@ copy: src: "motd-news" dest: "/etc/default/motd-news" + tags: [ motd ] - name: Disable default update-motd tasks file: path: "/etc/update-motd.d/{{ item }}" @@ -49,7 +50,14 @@ - "92-unattended-upgrades" - "95-hwe-eol" - "97-overlayroot" + tags: [ motd ] when: ansible_distribution == "Ubuntu" + - name: Add update-motd tasks + template: + src: 50-ansible-motd.sh + dest: /etc/update-motd.d/50-ansible + mode: "0755" + tags: [ motd ] - name: Configure Ansible user include_tasks: ansibleuser.yml become: yes diff --git a/roles/common/templates/50-ansible-motd.sh b/roles/common/templates/50-ansible-motd.sh new file mode 100755 index 0000000..6d13fe3 --- /dev/null +++ b/roles/common/templates/50-ansible-motd.sh @@ -0,0 +1,34 @@ +#! /bin/sh +# +# 50-ansible-motd.sh +# Copyright (C) 2020 Vintage Salt +# +# Distributed under terms of the MIT license. +# + +# Service statuses +if command -v systemctl > /dev/null 2>&1; then + len=20 + printf "Services:\n" + for unit in \ + 9iron-backup \ + ansible-pull + do + systemctl status $unit > /dev/null 2>&1 + case $? in + 0) + printf " * %-${len}.${len}s\e[32mRunning\e[0m\n" $unit + ;; + 1|2) + printf " * %-${len}.${len}s\e[31mDead\e[0m\n" $unit + ;; + 3) + printf " * %-${len}.${len}s\e[34mExited\e[0m\n" $unit + ;; + *) + printf " * %-${len}.${len}s\e[33mUnknown\e[0m\n" "$unit" + ;; + esac + done +fi + diff --git a/roles/desktop-common/tasks/packages.yml b/roles/desktop-common/tasks/packages.yml index 196197c..0ee430e 100644 --- a/roles/desktop-common/tasks/packages.yml +++ b/roles/desktop-common/tasks/packages.yml @@ -19,10 +19,14 @@ url: "{{ item }}" loop: - "https://packages.riot.im/debian/riot-im-archive-keyring.gpg" # Element + - "https://download.spotify.com/debian/pubkey.gpg" # Spotify 1 + - "https://download.spotify.com/debian/pubkey_0D811D58.gpg" # Spotify 2 - name: Add repos apt_repository: repo: "{{ item }}" loop: + # Spotify + - "deb http://repository.spotify.com stable non-free" # Monodevelop - "deb https://download.mono-project.com/repo/ubuntu vs-bionic main" # Element @@ -151,6 +155,8 @@ - retroarch - rofi - scrot + - slack-desktop + - spotify-client - steam-installer - syncthing-gtk - telegram-desktop @@ -191,6 +197,7 @@ apt: deb: "{{ item }}" loop: + - "https://downloads.slack-edge.com/linux_releases/slack-desktop-4.8.0-amd64.deb" - "https://github.com/MultiMC/MultiMC5/releases/download/0.6.8/multimc_1.4-1.deb" - "https://zoom.us/client/latest/zoom_amd64.deb" - name: Install desktop applications through pip3 @@ -207,18 +214,13 @@ - discord - sengi - scrcpy # Remote Android viewing - - spotify # Forgive me father - - name: Install Snap applications classically - snap: - classic: yes - name: "{{ item }}" - loop: - - slack - name: Remove Snap applications snap: name: - pixelorama - riot-web + - slack + - spotify state: absent - name: Remove desktop applications through APT apt: diff --git a/roles/pulseaudio/tasks/main.yml b/roles/pulseaudio/tasks/main.yml new file mode 100644 index 0000000..3c01464 --- /dev/null +++ b/roles/pulseaudio/tasks/main.yml @@ -0,0 +1,32 @@ +#!/usr/bin/ansible-playbook +# vim:ft=ansible: +--- +- name: Install and configure PulseAudio + block: + - name: Install packages + apt: + name: + - pulseaudio + - name: Template out configs + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + mode: "{{ item.mode }}" + loop: + - { src: "pulse-client.conf", dest: "/etc/pulse/client.conf", mode: "0644" } + - { src: "pulse-daemon.conf", dest: "/etc/pulse/daemon.conf", mode: "0644" } + - { src: "pulse-default.pa", dest: "/etc/pulse/default.pa", mode: "0644" } + - { src: "pulseaudio.service", dest: "/etc/systemd/system/pulseaudio.service", mode: "0644" } + - name: Assure pulse user + user: + name: pulseaudio + password: "!" + system: yes + home: /var/lib/pulse + groups: audio + - name: Enable service + systemd: + name: pulseaudio + enabled: yes + daemon_reload: yes + become: yes diff --git a/roles/pulseaudio/templates/pulse-client.conf b/roles/pulseaudio/templates/pulse-client.conf new file mode 100644 index 0000000..116187e --- /dev/null +++ b/roles/pulseaudio/templates/pulse-client.conf @@ -0,0 +1,3 @@ +# Managed via Ansible +autospawn = no +default-server = unix:/tmp/pulse-server diff --git a/roles/pulseaudio/templates/pulse-daemon.conf b/roles/pulseaudio/templates/pulse-daemon.conf new file mode 100644 index 0000000..11af05c --- /dev/null +++ b/roles/pulseaudio/templates/pulse-daemon.conf @@ -0,0 +1,23 @@ +# Configuration file for the PulseAudio daemon. See pulse-daemon.conf(5) for +# more information. Default values are commented out. Use either ; or # for +# commenting. + +# Bugfixes for my desktop's audio card +realtime-scheduling = no # Fixes a weird stutter issue + +# Sanity +flat-volumes = no + +# Audio Quality +default-sample-format = s32le # Pulse does 16bit sampling by default for some reason +default-sample-rate = 48000 # Higher sample rate than default +alternate-sample-rate = 44100 +resample-method = speex-float-5 # Increase resampling quality +avoid-resampling = true + +default-fragments = 5 # Pulse, why are you so friggin latent by default? +default-fragment-size-msec = 10 + +high-priority = yes +nice-level = -19 + diff --git a/roles/pulseaudio/templates/pulse-default.pa b/roles/pulseaudio/templates/pulse-default.pa new file mode 100644 index 0000000..464f143 --- /dev/null +++ b/roles/pulseaudio/templates/pulse-default.pa @@ -0,0 +1,77 @@ +#!/usr/bin/pulseaudio -nF +#!/usr/bin/pulseaudio -nF +# +.fail + +load-module module-device-restore +load-module module-stream-restore +load-module module-card-restore +load-module module-augment-properties +### Should be after module-*-restore but before module-*-detect +load-module module-switch-on-port-available +### Use hot-plugged devices like Bluetooth or USB automatically (LP: #1702794) +.ifexists module-switch-on-connect.so +load-module module-switch-on-connect +.endif + +# Device detection +.ifexists module-udev-detect.so +load-module module-udev-detect +.else +load-module module-detect +.endif + +# Bluetooth +.ifexists module-bluetooth-policy.so +load-module module-bluetooth-policy +.endif +.ifexists module-bluetooth-discover.so +load-module module-bluetooth-discover +.endif + +# Protocols +.ifexists module-esound-protocol-unix.so +load-module module-esound-protocol-unix +.endif +load-module module-native-protocol-unix auth-group=audio socket=/tmp/pulse-server + +# Load GSettings/paprefs modules +.ifexists module-gsettings.so +.nofail +load-module module-gsettings +.fail +.endif + +load-module module-default-device-restore +load-module module-always-sink +load-module module-intended-roles +load-module module-suspend-on-idle + +### If autoexit on idle is enabled we want to make sure we only quit +### when no local session needs us anymore. +.ifexists module-console-kit.so +load-module module-console-kit +.endif +.ifexists module-systemd-login.so +load-module module-systemd-login +.endif + +# Enable positioned event sounds +load-module module-position-event-sounds +# Cork music/video streams when a phone stream is active +load-module module-role-cork +# Block audio recording for snap confined packages +.ifexists module-snap-policy.so +load-module module-snap-policy +.endif + +load-module module-filter-heuristics +load-module module-filter-apply + +## Gets around a weird audio skipping bug on my desktop +.ifexists module-udev-detect.so +load-module module-udev-detect tsched=0 + +## My laptop gets sink suspension popping when using headphones +unload-module module-suspend-on-idle + diff --git a/roles/pulseaudio/templates/pulseaudio.service b/roles/pulseaudio/templates/pulseaudio.service new file mode 100644 index 0000000..3d07b92 --- /dev/null +++ b/roles/pulseaudio/templates/pulseaudio.service @@ -0,0 +1,23 @@ +# vim:ft=systemd +# NOTE: This service is ONLY useful IF you have the following: +# * client.conf is set to not autospawn and listen to a socket instead +# * default.pa is configured to start such a socket +# Using this unit file and complaining to me that it doesn't work without +# the other configs in place will result in me not giving a shit + +## THIS UNIT DOES NOT START PULSE IN SYSTEM MODE +## THIS UNIT DOES NOT START PULSE IN SYSTEM MODE +## THIS UNIT DOES NOT START PULSE IN SYSTEM MODE +## THIS UNIT DOES NOT START PULSE IN SYSTEM MODE +## THIS UNIT DOES NOT START PULSE IN SYSTEM MODE +[Unit] +Description=Pulseaudio sound server + +[Service] +User=pulseaudio +Group=pulseaudio +ExecStart=/usr/bin/pulseaudio --disallow-exit +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target