audio: refactor with argc
Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
parent
f9377d7686
commit
20cd92006e
4 changed files with 69 additions and 8 deletions
|
@ -180,7 +180,7 @@ in {
|
||||||
(key "Up" "Super" "movewindow" "u")
|
(key "Up" "Super" "movewindow" "u")
|
||||||
(key "Up" "Super+Shift" "movewindoworgroup" "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 "0" "Super+Shift" "exec" "${zoom}")
|
||||||
(key "1" "Ctrl+Alt" "exec" "lifx state --brightness 0.01")
|
(key "1" "Ctrl+Alt" "exec" "lifx state --brightness 0.01")
|
||||||
(key "1" "Super" "workspace" "1")
|
(key "1" "Super" "workspace" "1")
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
_1password = "${config.programs._1password-gui.package}/bin/1password";
|
_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";
|
clipse = "${pkgs.clipse}/bin/clipse";
|
||||||
firefox-esr = "${
|
firefox-esr = "${
|
||||||
config.home-manager.users.${config.custom.username}.programs.firefox.finalPackage
|
config.home-manager.users.${config.custom.username}.programs.firefox.finalPackage
|
||||||
|
@ -72,6 +73,7 @@ in {
|
||||||
optionals config.custom.wallpaper ["wallpaper"]
|
optionals config.custom.wallpaper ["wallpaper"]
|
||||||
++ [
|
++ [
|
||||||
sway-audio-idle-inhibit # Inhibit idle while audio is playing
|
sway-audio-idle-inhibit # Inhibit idle while audio is playing
|
||||||
|
"${audio} --init" # Enforce audio profile state
|
||||||
"${clipse} --clear" # Clear clipboard history
|
"${clipse} --clear" # Clear clipboard history
|
||||||
"${clipse} --listen" # Monitor clipboard
|
"${clipse} --listen" # Monitor clipboard
|
||||||
"${_1password} --silent" # Launch password manager in background
|
"${_1password} --silent" # Launch password manager in background
|
||||||
|
|
|
@ -1,11 +1,68 @@
|
||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
if [[ -v 1 ]]; then
|
# @describe Wrapper for toggling between audio profiles
|
||||||
easyeffects --load-preset "$1" &&
|
#
|
||||||
easyeffects --bypass 2
|
# https://github.com/sigoden/argc
|
||||||
notify-send '> audio' "$1" --urgency low
|
|
||||||
|
# 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
|
else
|
||||||
easyeffects --load-preset Flat &&
|
# Create file with flat profile if missing
|
||||||
easyeffects --bypass 1
|
profile="${argc_flat:-}"
|
||||||
notify-send '> audio' 'Bypass' --urgency low
|
echo "$profile" > "${argc_file:-}"
|
||||||
fi
|
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:-}"
|
||||||
|
|
|
@ -48,6 +48,8 @@ in {
|
||||||
[
|
[
|
||||||
# Bash files with extension .sh
|
# Bash files with extension .sh
|
||||||
(bash "audio" [
|
(bash "audio" [
|
||||||
|
argc
|
||||||
|
coreutils
|
||||||
easyeffects
|
easyeffects
|
||||||
libnotify
|
libnotify
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in a new issue