Skip to content

Commit

Permalink
feat: include fuzzy audio sink option
Browse files Browse the repository at this point in the history
  • Loading branch information
MSchmoecker authored and elikoga committed Nov 13, 2024
1 parent 1415084 commit e457edd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions controller/thymis_controller/modules/kiosk.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ class Kiosk(modules.Module):
order=55,
)

audio_sink_fuzzy = modules.Setting(
display_name=modules.LocalizedString(
en="Audio Sink",
de="Audio Sink",
),
type="string",
default="",
description="Select the audio sink via a fuzzy search. Eg. 'audio' or 'hdmi' can be used to match the default output or HDMI on a Raspberry Pi 3.\nTo list available sinks, the following commands can be used on the device:\n> machinectl shell [email protected]\n> pactl list short sinks",
example="HDMI",
order=57,
)

enable_vnc = modules.Setting(
display_name=modules.LocalizedString(
en="Enable VNC server",
Expand Down Expand Up @@ -119,6 +131,12 @@ def write_nix_settings(

volume = max(0, min(100, int(volume)))

audio_sink_fuzzy = (
module_settings.settings["audio_sink_fuzzy"]
if "audio_sink_fuzzy" in module_settings.settings
else self.audio_sink_fuzzy.default
)

nonce = hash(str(module_settings.__dict__))

f.write(
Expand Down Expand Up @@ -148,6 +166,7 @@ def write_nix_settings(
{'exec ${pkgs.bash}/bin/bash -c "mkdir -p $HOME/tigervnc; ${pkgs.tigervnc}/bin/vncpasswd -f <<< \\"'+ vnc_password + '\\" > $HOME/tigervnc/passwd"' if enable_vnc else ''}
{'exec ${pkgs.tigervnc}/bin/x0vncserver -display :0 -PasswordFile=$HOME/tigervnc/passwd' if enable_vnc else ''}
exec "${{pkgs.pamixer}}/bin/pamixer --set-volume {volume}"
{f'exec "${{pkgs.pulseaudio}}/bin/pactl set-default-sink \'\'$(${{pkgs.pulseaudio}}/bin/pactl list short sinks | grep -m1 -i \'{audio_sink_fuzzy}\' | cut -f1)"' if audio_sink_fuzzy else ''}
'');
systemd.services.display-manager.restartIfChanged = lib.mkOverride {priority} true;
systemd.services.display-manager.environment.NONCE = lib.mkOverride {priority} "{nonce}";
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/config/ModuleCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</script>

<Card
class="max-w-none grid grid-cols-[minmax(50px,3fr)_1fr] sm:grid-cols-[auto_150px] xl:grid-cols-[auto_250px] gap-4"
class="max-w-none grid grid-cols-[minmax(50px,3fr)_1fr] sm:grid-cols-[auto_250px] xl:grid-cols-[auto_350px] gap-4"
padding={'sm'}
>
{#each settingEntries as [key, setting]}
Expand Down Expand Up @@ -146,7 +146,7 @@
{/if}
</div>
</div>
<P class="mt-6">{setting.description}</P>
<P class="mt-6 whitespace-pre-line">{setting.description}</P>
{:else}
<div>{$t('config.no-settings')}</div>
{/each}
Expand Down

0 comments on commit e457edd

Please sign in to comment.