1
1
Fork 0

audio: refactor with argc

Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
Myned 2024-09-27 14:51:18 -05:00
parent f9377d7686
commit 20cd92006e
Signed by: myned
GPG key ID: C7224454F7881A34
4 changed files with 69 additions and 8 deletions

View file

@ -180,7 +180,7 @@ in {
(key "Up" "Super" "movewindow" "u")
(key "Up" "Super+Shift" "movewindoworgroup" "u")
(key "0" "Super" "exec" "${audio}")
(key "0" "Super" "exec" "${audio} --bypass")
(key "0" "Super+Shift" "exec" "${zoom}")
(key "1" "Ctrl+Alt" "exec" "lifx state --brightness 0.01")
(key "1" "Super" "workspace" "1")

View file

@ -6,6 +6,7 @@
}:
with lib; let
_1password = "${config.programs._1password-gui.package}/bin/1password";
audio = config.home-manager.users.${config.custom.username}.home.file.".local/bin/audio".source;
clipse = "${pkgs.clipse}/bin/clipse";
firefox-esr = "${
config.home-manager.users.${config.custom.username}.programs.firefox.finalPackage
@ -72,6 +73,7 @@ in {
optionals config.custom.wallpaper ["wallpaper"]
++ [
sway-audio-idle-inhibit # Inhibit idle while audio is playing
"${audio} --init" # Enforce audio profile state
"${clipse} --clear" # Clear clipboard history
"${clipse} --listen" # Monitor clipboard
"${_1password} --silent" # Launch password manager in background

View file

@ -1,11 +1,68 @@
#! /usr/bin/env bash
if [[ -v 1 ]]; then
easyeffects --load-preset "$1" &&
easyeffects --bypass 2
notify-send '> audio' "$1" --urgency low
# @describe Wrapper for toggling between audio profiles
#
# https://github.com/sigoden/argc
# HACK: Condition based on file content, requires execution at login to set state
#?? exec-once = audio --init
# @meta combine-shorts
# @arg profile=Normalizer EasyEffects profile to toggle to
# @option -F --flat=`_default_flat` Flat profile to toggle from
# @option -f --file=`_default_file` Specify file for state
# @flag -b --bypass Toggle bypass instead of flat profile
# @flag -i --init Enforce state without toggling
_default_file() {
echo "$HOME/.audio"
}
_default_flat() {
echo Flat
}
eval "$(argc --argc-eval "$0" "$@")"
# Get current profile from file
if [[ -f "${argc_file:-}" ]]; then
profile="$(cat "${argc_file:-}")"
else
easyeffects --load-preset Flat &&
easyeffects --bypass 1
notify-send '> audio' 'Bypass' --urgency low
# Create file with flat profile if missing
profile="${argc_flat:-}"
echo "$profile" > "${argc_file:-}"
fi
# Toggle profile
if ! [[ "${argc_init:-}" ]]; then
if [[ "$profile" == "${argc_profile:-}" ]]; then
# Flat or bypass
if [[ "${argc_bypass:-}" ]]; then
profile=1
else
profile="${argc_flat:-}"
fi
else
# Specified profile
profile="${argc_profile:-}"
fi
fi
# Enforce profile
if [[ "$profile" == 1 ]]; then
easyeffects --bypass 1 # Enable
if ! [[ "${argc_init:-}" ]]; then
notify-send "> audio" "Bypass" --urgency low
fi
else
easyeffects --load-preset "$profile"
easyeffects --bypass 2 # Disable
if ! [[ "${argc_init:-}" ]]; then
notify-send "> audio" "$profile" --urgency low
fi
fi
# Save state
echo "$profile" > "${argc_file:-}"

View file

@ -48,6 +48,8 @@ in {
[
# Bash files with extension .sh
(bash "audio" [
argc
coreutils
easyeffects
libnotify
])