From c7cfdb386430b01fd9748139a0e9cfa40e36c265 Mon Sep 17 00:00:00 2001 From: diniamo Date: Sun, 29 Sep 2024 14:55:46 +0200 Subject: [PATCH] spotify-player: add support for actions Actions were added in the v0.19.1 release. --- modules/programs/spotify-player.nix | 44 ++++++++++++++++--- .../programs/spotify-player/keymap.toml | 13 ++++++ .../programs/spotify-player/settings.nix | 16 +++++++ 3 files changed, 66 insertions(+), 7 deletions(-) diff --git a/modules/programs/spotify-player.nix b/modules/programs/spotify-player.nix index 83eefe12d..35d3933bc 100644 --- a/modules/programs/spotify-player.nix +++ b/modules/programs/spotify-player.nix @@ -1,12 +1,12 @@ { config, lib, pkgs, ... }: let - inherit (lib) - mkEnableOption mkPackageOption mkOption types literalExpression mkIf; + inherit (lib) mkEnableOption mkPackageOption mkOption literalExpression mkIf; + inherit (lib.types) listOf; cfg = config.programs.spotify-player; tomlFormat = pkgs.formats.toml { }; - + tomlType = tomlFormat.type; in { meta.maintainers = with lib.hm.maintainers; [ diniamo ]; @@ -16,7 +16,7 @@ in { package = mkPackageOption pkgs "spotify-player" { }; settings = mkOption { - type = tomlFormat.type; + type = tomlType; default = { }; example = literalExpression '' { @@ -43,7 +43,7 @@ in { }; themes = mkOption { - type = types.listOf tomlFormat.type; + type = listOf tomlType; default = [ ]; example = literalExpression '' [ @@ -94,7 +94,7 @@ in { }; keymaps = mkOption { - type = types.listOf tomlFormat.type; + type = listOf tomlType; default = [ ]; example = literalExpression '' [ @@ -129,6 +129,36 @@ in { for the full list of options. ''; }; + + actions = mkOption { + type = listOf tomlType; + default = [ ]; + example = literalExpression '' + [ + { + action = "GoToArtist"; + key_sequence = "g A"; + } + { + action = "GoToAlbum"; + key_sequence = "g B"; + target = "PlayingTrack"; + } + { + action = "ToggleLiked"; + key_sequence = "C-l"; + } + ] + ''; + description = '' + Configuration written to the `actions` field of + {file}`$XDG_CONFIG_HOME/spotify-player/keymap.toml`. + + See + + for the full list of options. + ''; + }; }; config = mkIf cfg.enable { @@ -146,7 +176,7 @@ in { "spotify-player/keymap.toml" = mkIf (cfg.keymaps != [ ]) { source = tomlFormat.generate "spotify-player-keymap" { - inherit (cfg) keymaps; + inherit (cfg) keymaps actions; }; }; }; diff --git a/tests/modules/programs/spotify-player/keymap.toml b/tests/modules/programs/spotify-player/keymap.toml index d11c86e41..29cac4781 100644 --- a/tests/modules/programs/spotify-player/keymap.toml +++ b/tests/modules/programs/spotify-player/keymap.toml @@ -1,3 +1,16 @@ +[[actions]] +action = "GoToArtist" +key_sequence = "g A" + +[[actions]] +action = "GoToAlbum" +key_sequence = "g B" +target = "PlayingTrack" + +[[actions]] +action = "ToggleLiked" +key_sequence = "C-l" + [[keymaps]] command = "NextTrack" key_sequence = "g n" diff --git a/tests/modules/programs/spotify-player/settings.nix b/tests/modules/programs/spotify-player/settings.nix index dc7fe8c6a..e0442360b 100644 --- a/tests/modules/programs/spotify-player/settings.nix +++ b/tests/modules/programs/spotify-player/settings.nix @@ -87,6 +87,22 @@ key_sequence = "q"; } ]; + + actions = [ + { + action = "GoToArtist"; + key_sequence = "g A"; + } + { + action = "GoToAlbum"; + key_sequence = "g B"; + target = "PlayingTrack"; + } + { + action = "ToggleLiked"; + key_sequence = "C-l"; + } + ]; }; test.stubs.spotify-player = { };