Skip to content

Commit 2c21db7

Browse files
kajusnaubrianmcgillion
authored andcommitted
audio: fix dropped pipewire messages
- use pulseaudio controls for keyboard shortcuts - fixes an issue where audio keyboard shortcuts might be ignored - reduce amount of givc/pipewire logs in gui and audio vm Signed-off-by: Kajus Naujokaitis <[email protected]>
1 parent 93eb002 commit 2c21db7

File tree

5 files changed

+33
-41
lines changed

5 files changed

+33
-41
lines changed

modules/common/services/audio/server.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ in
9898
# but keep it for compatibility with CLI tools
9999
{
100100
"address" = "tcp:${toString cfg.server.pulseaudioTcpPort}"; # address
101-
"max-clients" = 8; # maximum number of clients
101+
"max-clients" = 32; # maximum number of clients
102102
"listen-backlog" = 32; # backlog in the server listen queue
103103
"client.access" = "restricted"; # permissions for clients (restricted|unrestricted)
104104
}
105105
{
106106
"address" = "tcp:${toString cfg.server.pulseaudioTcpControlPort}";
107-
"max-clients" = 8;
107+
"max-clients" = 32;
108108
"listen-backlog" = 32;
109109
"client.access" = "unrestricted";
110110
}

modules/desktop/graphics/cosmic/config/cosmic-config.nix

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -98,58 +98,56 @@ let
9898
'') extraShortcuts}
9999
''
100100
);
101+
101102
ghaf-volume = pkgs.writeShellApplication {
102103
name = "ghaf-volume";
103104

104105
runtimeInputs = with pkgs; [
105-
wireplumber
106106
pulseaudio
107+
pamixer
107108
];
108109

109110
text = ''
110-
export PIPEWIRE_RUNTIME_DIR=/tmp
111-
112111
AMP_FILE="$HOME/.config/cosmic/com.system76.CosmicAudio/v1/amplification_sink"
113-
# Enable amplification by default, following COSMIC upstream behavior
114-
AMP_ENABLED="true"
115-
LIMIT=1.5
116112
VOLUME_CHANGE_SOUND="/run/current-system/sw/share/sounds/freedesktop/stereo/audio-volume-change.oga"
117113
118-
exit_error() {
119-
echo "Usage: ghaf-volume {up|down}"
120-
exit 1
121-
}
122-
123-
DIR=''${1:-}
124-
125-
[ -z "$DIR" ] && exit_error
126-
127-
if [ -f "$AMP_FILE" ] && [ -s "$AMP_FILE" ]; then
128-
VALUE=$(tr -d '[:space:]' < "$AMP_FILE")
129-
if [[ "$VALUE" == "true" || "$VALUE" == "false" ]]; then
130-
AMP_ENABLED="$VALUE"
131-
fi
114+
# Enable amplification by default, following COSMIC upstream behavior
115+
AMP_ENABLED=true
116+
LIMIT=150
117+
118+
# Fast argument parsing
119+
case "$1" in
120+
up) DIR=-i ;;
121+
down) DIR=-d ;;
122+
*) echo "Usage: ghaf-volume {up|down}" >&2; exit 1 ;;
123+
esac
124+
125+
if [[ -s "$AMP_FILE" ]]; then
126+
read -r AMP_ENABLED < "$AMP_FILE" || true
132127
fi
133128
134-
[[ "$AMP_ENABLED" == "false" ]] && LIMIT=1.0
129+
[[ "$AMP_ENABLED" == "false" ]] && LIMIT=100
135130
136-
if [[ "$DIR" == "up" ]]; then
137-
DIR=+
138-
elif [[ "$DIR" == "down" ]]; then
139-
DIR=-
131+
if [[ "$AMP_ENABLED" != "true" ]]; then
132+
LIMIT=100
133+
BOOST=""
140134
else
141-
exit_error
135+
BOOST="--allow-boost"
142136
fi
143137
144-
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 &
145-
wpctl set-volume @DEFAULT_AUDIO_SINK@ "5%$DIR" -l $LIMIT
146-
paplay "$VOLUME_CHANGE_SOUND"
138+
CUR_VOLUME=$(pamixer --get-volume)
139+
140+
pamixer --unmute $DIR 5 --set-limit $LIMIT $BOOST
141+
142+
# Play sound only if volume changed
143+
NEW_VOLUME=$(pamixer --get-volume)
144+
[[ "$CUR_VOLUME" != "$NEW_VOLUME" ]] && paplay "$VOLUME_CHANGE_SOUND"
147145
'';
148146
};
149147
in
150148
pkgs.stdenv.mkDerivation {
151149
pname = "ghaf-cosmic-config";
152-
version = "0.2";
150+
version = "0.3";
153151

154152
phases = [
155153
"unpackPhase"

modules/desktop/graphics/cosmic/config/cosmic-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,9 @@ com.system76.CosmicSettings.Shortcuts:
353353
/// Locks the screen
354354
LockScreen: "loginctl lock-session",
355355
/// Mutes the active output device
356-
Mute: "PIPEWIRE_RUNTIME_DIR=/tmp wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle",
356+
Mute: "pactl set-sink-mute @DEFAULT_SINK@ toggle",
357357
/// Mutes the active microphone
358-
MuteMic: "PIPEWIRE_RUNTIME_DIR=/tmp wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle",
358+
MuteMic: "pactl set-source-mute @DEFAULT_SOURCE@ toggle",
359359
/// Plays and Pauses audio
360360
PlayPause: "playerctl play-pause",
361361
/// Goes to the next track

modules/desktop/graphics/cosmic/default.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ in
348348

349349
text = ''
350350
PROCESSES=("cosmic-osd")
351-
KILLABLES=("cosmic-osd")
352351
353352
THRESHOLD=80
354353
INTERVAL=10
@@ -366,7 +365,7 @@ in
366365
if (( CPU > THRESHOLD )); then
367366
if (( NOW - LAST_KILL >= COOLDOWN )); then
368367
echo "$(date) High CPU detected ($PROC: ''${CPU}%), killing processes..."
369-
for KILL_PROC in "''${KILLABLES[@]}"; do
368+
for KILL_PROC in "''${PROCESSES[@]}"; do
370369
pkill -xf "$KILL_PROC" && echo "$(date) Killed $KILL_PROC"
371370
done
372371
LAST_KILL=$NOW

modules/microvm/sysvms/guivm.nix

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,6 @@ let
238238
pkgs.gnome-calculator
239239
pkgs.sticky-notes
240240
])
241-
++ [
242-
pkgs.pamixer
243-
pkgs.eww
244-
pkgs.wlr-randr
245-
]
246241
++ [ pkgs.ctrl-panel ]
247242
# For GIVC debugging/testing
248243
++ lib.optional config.ghaf.profiles.debug.enable pkgs.givc-cli

0 commit comments

Comments
 (0)