hyprland: add KEF optical shortcut
This commit is contained in:
@@ -262,6 +262,7 @@ function M.setup(ctx)
|
||||
bind(hyper .. " + backslash", exec("/home/imalison/dotfiles/dotfiles/lib/functions/mpg341cx_input toggle"))
|
||||
bind(hyper .. " + SHIFT + backslash", workspacehistory("debug"))
|
||||
bind(hyper .. " + O", exec("/home/imalison/dotfiles/dotfiles/lib/functions/rofi_paswitch"))
|
||||
bind(hyper .. " + SHIFT + O", exec("/home/imalison/dotfiles/dotfiles/lib/bin/kef-optical"))
|
||||
bind(hyper .. " + comma", exec("rofi_wallpaper.sh"))
|
||||
bind(hyper .. " + SHIFT + comma", exec("/home/imalison/dotfiles/dotfiles/lib/bin/neowall-wallpaper toggle"))
|
||||
bind(hyper .. " + Y", exec("rofi_agentic_skill"))
|
||||
|
||||
@@ -15,7 +15,7 @@ MODEL_ALIASES = {
|
||||
}
|
||||
SOURCE_ALIASES = {
|
||||
"aux": "analog",
|
||||
"optical": "optic",
|
||||
"optic": "optical",
|
||||
}
|
||||
|
||||
|
||||
|
||||
33
dotfiles/lib/bin/kef-optical
Executable file
33
dotfiles/lib/bin/kef-optical
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
model="${KEF_MODEL:-${KEF_SPEAKER_MODEL:-LS50WII}}"
|
||||
discovery_timeout="${KEF_DISCOVERY_TIMEOUT:-5}"
|
||||
wake_delay="${KEF_WAKE_DELAY:-3}"
|
||||
host="${KEF_HOST:-${KEF_IP:-${KEF_SPEAKER_IP:-}}}"
|
||||
|
||||
kef_args=(--model "$model" --discovery-timeout "$discovery_timeout")
|
||||
if [[ -n "$host" ]]; then
|
||||
kef_args=(--host "$host" "${kef_args[@]}")
|
||||
fi
|
||||
|
||||
notify() {
|
||||
if command -v notify-send >/dev/null 2>&1; then
|
||||
notify-send "KEF speakers" "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
kef "${kef_args[@]}" on
|
||||
sleep "$wake_delay"
|
||||
|
||||
for _ in {1..10}; do
|
||||
if kef "${kef_args[@]}" source optical >/dev/null; then
|
||||
notify "Powered on and switched to optical"
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
notify "Powered on, but optical input switch failed"
|
||||
echo "kef-optical: powered on, but failed to switch to optical input" >&2
|
||||
exit 1
|
||||
@@ -360,21 +360,16 @@ from transformers import (/' \
|
||||
python-final: python-prev: {
|
||||
pykefcontrol = python-prev.buildPythonPackage rec {
|
||||
pname = "pykefcontrol";
|
||||
version = "0.9";
|
||||
version = "0.9.3-pr17";
|
||||
pyproject = true;
|
||||
|
||||
src = final.fetchFromGitHub {
|
||||
owner = "N0ciple";
|
||||
owner = "colonelpanic8";
|
||||
repo = "pykefcontrol";
|
||||
rev = "530a7d15cf692c35a7c181c8f5e28edc0f1e085a";
|
||||
hash = "sha256-V/uYzzUv/PslfZ/zSSAK4j6kI9lLQOXBN1AG0rjRrpg=";
|
||||
rev = "1eb4418ce39d9d368d4f195702215a7854790633";
|
||||
hash = "sha256-aqa0LP0cjT2F/vtoxKvCFPeBAWwReaF47QLT4KsOhjA=";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace pyproject.toml \
|
||||
--replace-fail 'version = "0.8"' 'version = "0.9"'
|
||||
'';
|
||||
|
||||
build-system = with python-final; [ hatchling ];
|
||||
propagatedBuildInputs = with python-final; [
|
||||
aiohttp
|
||||
|
||||
@@ -11,7 +11,8 @@ from pykefcontrol.kef_connector import KefConnector
|
||||
from zeroconf import IPVersion, ServiceBrowser, ServiceListener, Zeroconf
|
||||
|
||||
|
||||
SOURCES = ("wifi", "bluetooth", "tv", "optic", "coaxial", "analog", "standby")
|
||||
SOURCE_ALIASES = {"optic": "optical"}
|
||||
SOURCES = ("wifi", "bluetooth", "tv", "optical", "coaxial", "analog", "standby")
|
||||
DISCOVERY_SERVICE_TYPES = (
|
||||
"_kef-info._tcp.local.",
|
||||
"_sues800device._tcp.local.",
|
||||
@@ -163,6 +164,12 @@ def bounded_volume(value):
|
||||
return max(0, min(100, value))
|
||||
|
||||
|
||||
def normalize_source(source):
|
||||
if source is None:
|
||||
return None
|
||||
return SOURCE_ALIASES.get(source, source)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(prog="kef", description="Control KEF W2 speakers.")
|
||||
parser.add_argument(
|
||||
@@ -198,7 +205,7 @@ def main():
|
||||
down.add_argument("step", nargs="?", default=3, type=int)
|
||||
|
||||
source = subparsers.add_parser("source", help="Get or set source.")
|
||||
source.add_argument("name", nargs="?", choices=SOURCES)
|
||||
source.add_argument("name", nargs="?", choices=SOURCES + tuple(SOURCE_ALIASES))
|
||||
|
||||
subparsers.add_parser("play-pause", help="Toggle play/pause.")
|
||||
subparsers.add_parser("next", help="Next track.")
|
||||
@@ -233,7 +240,7 @@ def main():
|
||||
if args.name is None:
|
||||
print(speaker.source)
|
||||
else:
|
||||
speaker.source = args.name
|
||||
speaker.source = normalize_source(args.name)
|
||||
elif args.command == "play-pause":
|
||||
speaker.toggle_play_pause()
|
||||
elif args.command == "next":
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
{
|
||||
lib,
|
||||
buildPythonPackage,
|
||||
fetchPypi,
|
||||
fetchFromGitHub,
|
||||
hatchling,
|
||||
aiohttp,
|
||||
requests,
|
||||
}:
|
||||
buildPythonPackage rec {
|
||||
pname = "pykefcontrol";
|
||||
version = "0.9.2";
|
||||
version = "0.9.3-pr17";
|
||||
pyproject = true;
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
hash = "sha256-3kGhN+E7driiE6ePyF0EZOEnUhTm07sxHCKdzrn/MxM=";
|
||||
src = fetchFromGitHub {
|
||||
owner = "colonelpanic8";
|
||||
repo = "pykefcontrol";
|
||||
rev = "1eb4418ce39d9d368d4f195702215a7854790633";
|
||||
hash = "sha256-aqa0LP0cjT2F/vtoxKvCFPeBAWwReaF47QLT4KsOhjA=";
|
||||
};
|
||||
|
||||
build-system = [
|
||||
|
||||
Reference in New Issue
Block a user