From 383b649822096db7bab3a8e284b592d9b9d532e3 Mon Sep 17 00:00:00 2001 From: Fernando Rodrigues Date: Sun, 24 Nov 2024 12:06:02 +0000 Subject: [PATCH 1/6] feat(elisa): init (#391) Signed-off-by: Fernando Rodrigues Co-authored-by: Heitor Augusto --- modules/apps/default.nix | 1 + modules/apps/elisa.nix | 226 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 227 insertions(+) create mode 100644 modules/apps/elisa.nix diff --git a/modules/apps/default.nix b/modules/apps/default.nix index 80974fd5..a8d827db 100644 --- a/modules/apps/default.nix +++ b/modules/apps/default.nix @@ -2,6 +2,7 @@ { imports = [ + ./elisa.nix ./ghostwriter.nix ./konsole.nix ./kate diff --git a/modules/apps/elisa.nix b/modules/apps/elisa.nix new file mode 100644 index 00000000..8d57df98 --- /dev/null +++ b/modules/apps/elisa.nix @@ -0,0 +1,226 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.programs.elisa; + + capitalizeWord = + word: + if word == null then + null + else + lib.concatImapStrings (pos: char: if pos == 1 then lib.toUpper char else char) ( + lib.stringToCharacters word + ); +in +{ + options.programs.elisa = { + enable = lib.mkEnableOption "the configuration module for Elisa, KDE's music player"; + package = + lib.mkPackageOption pkgs + [ + "kdePackages" + "elisa" + ] + { + nullable = true; + example = "pkgs.libsForQt5.elisa"; + extraDescription = '' + Use `pkgs.libsForQt5.elisa` for Plasma 5 or `pkgs.kdePackages.elisa` for Plasma 6. + You can also set this to `null` if you're using a system-wide installation of Elisa on NixOS. + ''; + }; + + appearance = { + colorScheme = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + example = "Krita dark orange"; + description = '' + The colour scheme of the UI. Leave this setting at `null` in order to + not override the systems default scheme for for this application. + ''; + }; + showNowPlayingBackground = lib.mkOption { + description = '' + Set to `true` in order to use a blurred version of the album artwork as the background for the 'Now Playing' section in Elisa. + Set to `false` in order to use a solid colour inherited from the Plasma theme. + ''; + default = null; + type = lib.types.nullOr lib.types.bool; + }; + showProgressOnTaskBar = lib.mkOption { + description = '' + Whether to present the current track progress in the task manager widgets in panels. + ''; + default = null; + type = lib.types.nullOr lib.types.bool; + }; + embeddedView = lib.mkOption { + description = '' + Select the sidebar-embedded view for Elisa. The selected view will + be omitted from the sidebar, and its contents will instead be individually + displayed after the main view buttons. + ''; + default = null; + type = lib.types.nullOr ( + lib.types.enum [ + "albums" + "artists" + "genres" + ] + ); + apply = capitalizeWord; + }; + defaultView = lib.mkOption { + description = '' + The default view which will be opened when Elisa is started. + ''; + default = null; + type = lib.types.nullOr ( + lib.types.enum [ + "nowPlaying" + "recentlyPlayed" + "frequentlyPlayed" + "allAlbums" + "allArtists" + "allTracks" + "allGenres" + "files" + "radios" + ] + ); + apply = capitalizeWord; + }; + defaultFilesViewPath = lib.mkOption { + description = '' + The default path which will be opened in the Files view. + Unlike the index paths, shell variables cannot be used here. + ''; + default = null; + example = "/home/username/Music"; + type = lib.types.nullOr lib.types.str; + }; + }; + + indexer = { + paths = lib.mkOption { + description = '' + Stateful, persistent paths to be indexed by the Elisa Indexer. + The Indexer will recursively search for valid music files along the given paths. + Shell variables, such as `$HOME`, may be used freely. + ''; + default = null; + example = '' + [ + "$HOME/Music" + "/ExternalDisk/more-music" + ] + ''; + type = lib.types.nullOr (lib.types.listOf lib.types.str); + }; + scanAtStartup = lib.mkOption { + description = "Whether to automatically scan the configured index paths for new tracks when Elisa is started."; + default = null; + example = true; + type = lib.types.nullOr lib.types.bool; + }; + ratingsStyle = lib.mkOption { + description = '' + The Elisa music database can attach user-defined ratings to each track. + This option defines if the rating is a `0-5 stars` rating, or a binary `Favourite/Not Favourite` rating. + ''; + default = null; + type = lib.types.nullOr ( + lib.types.enum [ + "stars" + "favourites" + ] + ); + }; + }; + + player = { + playAtStartup = lib.mkOption { + description = "Whether to automatically play the previous track when Elisa is started."; + default = null; + type = lib.types.nullOr lib.types.bool; + }; + minimiseToSystemTray = lib.mkOption { + description = '' + Set to `true` in order to make Elisa continue playing in the System Tray after being closed. + Set to `false` in order to make Elisa quit after being closed. + + By default, the system tray icon is the symbolic variant of the Elisa icon. + ''; + default = null; + type = lib.types.nullOr lib.types.bool; + }; + useAbsolutePlaylistPaths = lib.mkOption { + description = '' + Set to `true` in order to make Elisa write `.m3u8` playlist files using the absolute paths to each track. + Setting to `false` will make Elisa intelligently pick between relative or absolute paths. + ''; + default = null; + type = lib.types.nullOr lib.types.bool; + }; + }; + }; + + config = lib.mkIf cfg.enable { + home.packages = lib.mkIf (cfg.package != null) [ cfg.package ]; + programs.plasma.configFile."elisarc" = + let + concatenatedPaths = builtins.concatStringsSep "," cfg.indexer.paths; + in + lib.mkMerge [ + (lib.mkIf (cfg.indexer.paths != null) { + ElisaFileIndexer.RootPath = { + shellExpand = true; + value = concatenatedPaths; + }; + }) + (lib.mkMerge [ + (lib.mkIf (cfg.player.playAtStartup != null) { + PlayerSettings.PlayAtStartup.value = cfg.player.playAtStartup; + }) + (lib.mkIf (cfg.indexer.scanAtStartup != null) { + PlayerSettings.ScanAtStartup.value = cfg.indexer.scanAtStartup; + }) + (lib.mkIf (cfg.appearance.showNowPlayingBackground != null) { + PlayerSettings.ShowNowPlayingBackground.value = cfg.appearance.showNowPlayingBackground; + }) + (lib.mkIf (cfg.appearance.showProgressOnTaskBar != null) { + PlayerSettings.ShowProgressOnTaskBar.value = cfg.appearance.showProgressOnTaskBar; + }) + (lib.mkIf (cfg.player.minimiseToSystemTray != null) { + PlayerSettings.ShowSystemTrayIcon.value = cfg.player.minimiseToSystemTray; + }) + (lib.mkIf (cfg.indexer.ratingsStyle != null) { + PlayerSettings.UseFavoriteStyleRatings.value = + if (cfg.indexer.ratingsStyle == "Stars") then false else true; + }) + ]) + (lib.mkIf (cfg.player.useAbsolutePlaylistPaths != null) { + Playlist.AlwaysUseAbsolutePlaylistPaths.value = cfg.player.useAbsolutePlaylistPaths; + }) + (lib.mkIf (cfg.appearance.colorScheme != null) { + UiSettings.ColorScheme.value = cfg.appearance.colorScheme; + }) + (lib.mkMerge [ + (lib.mkIf (cfg.appearance.embeddedView != null) { + Views.EmbeddedView.value = "All" + cfg.appearance.embeddedView; + }) + (lib.mkIf (cfg.appearance.defaultFilesViewPath != null) { + Views.InitialFilesViewPath.value = cfg.appearance.defaultFilesViewPath; + }) + (lib.mkIf (cfg.appearance.defaultView != null) { + Views.InitialView.value = cfg.appearance.defaultView; + }) + ]) + ]; + }; +} From 8e75ad96bfcc1a4da33b51c8a82adc146b2be011 Mon Sep 17 00:00:00 2001 From: Heitor Augusto Date: Sun, 24 Nov 2024 09:18:55 -0300 Subject: [PATCH 2/6] fix: update deprecated substituteInPlace syntax (#421) - Change --replace to --replace-fail in plasma-manager-options.nix - Update both options.md and manual.md substitutions - Maintain same substitution behavior but use supported syntax This removes usage of deprecated substituteInPlace --replace flag. --- docs/plasma-manager-options.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/plasma-manager-options.nix b/docs/plasma-manager-options.nix index 97e2ef99..e8e69935 100644 --- a/docs/plasma-manager-options.nix +++ b/docs/plasma-manager-options.nix @@ -28,12 +28,12 @@ stdenv.mkDerivation { cp ${./static/style.css} out/style.css substituteInPlace options.md \ - --replace \ + --replace-fail \ '@OPTIONS_JSON@' \ ${plasma-manager-options}/share/doc/nixos/options.json substituteInPlace manual.md \ - --replace \ + --replace-fail \ '@VERSION@' \ ${revision} From 16d65cd02b5de665d1bcfec1616c02c71a1014a6 Mon Sep 17 00:00:00 2001 From: Heitor Augusto Date: Sun, 24 Nov 2024 13:28:18 -0300 Subject: [PATCH 3/6] refactor(kwin): constrain tiling padding range to 0-36 (#422) --- modules/kwin.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/kwin.nix b/modules/kwin.nix index 2a16705d..dde2f4bc 100644 --- a/modules/kwin.nix +++ b/modules/kwin.nix @@ -411,7 +411,7 @@ in tiling = { padding = lib.mkOption { - type = with lib.types; nullOr ints.positive; + type = with lib.types; nullOr (ints.between 0 36); default = null; example = 10; description = "The padding between windows in tiling."; From 06e3209d11797d9c741e25df06ab61048746bf93 Mon Sep 17 00:00:00 2001 From: Thomas Bouvier Date: Tue, 26 Nov 2024 16:43:11 +0000 Subject: [PATCH 4/6] feat(icon-tasks): add iconsOnly option to icon-tasks module (#410) --- modules/widgets/icon-tasks.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/widgets/icon-tasks.nix b/modules/widgets/icon-tasks.nix index 73c55553..bdb342bd 100644 --- a/modules/widgets/icon-tasks.nix +++ b/modules/widgets/icon-tasks.nix @@ -77,6 +77,12 @@ in ]; description = "The list of launcher tasks on the widget. Usually .desktop file or executable URLs. Special URLs such as preferred://browser that expand to default applications are supported."; }; + iconsOnly = mkOption { + type = types.bool; + default = true; + example = false; + description = "Whether to show icons only."; + }; appearance = { showTooltips = mkBoolOption "Whether to show tooltips when hovering task buttons."; highlightWindows = mkBoolOption "Whether to request the window manager highlight windows when hovering corresponding task tooltips."; @@ -234,10 +240,13 @@ in behavior, launchers, settings, + iconsOnly, ... }: { - name = "org.kde.plasma.icontasks"; + name = if iconsOnly + then "org.kde.plasma.icontasks" + else "org.kde.plasma.taskmanager"; config = lib.recursiveUpdate { General = lib.filterAttrs (_: v: v != null) { launchers = launchers; From 02350cd23af955b7c858d4c640a5faa3eddcee29 Mon Sep 17 00:00:00 2001 From: Siddharth More <82610504+sidmoreoss@users.noreply.github.com> Date: Sun, 1 Dec 2024 02:02:21 +0530 Subject: [PATCH 5/6] feat(kwin): generate virtual desktop IDs (#408) Fixes #343 --- modules/kwin.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/kwin.nix b/modules/kwin.nix index dde2f4bc..42a93998 100644 --- a/modules/kwin.nix +++ b/modules/kwin.nix @@ -56,6 +56,11 @@ let names: builtins.listToAttrs (lib.imap1 (i: v: (lib.nameValuePair "Name_${builtins.toString i}" v)) names); + + virtualDesktopIdAttrs = + number: + builtins.listToAttrs (map (i: (lib.nameValuePair "Id_${builtins.toString i}" "Desktop_${builtins.toString i}")) (lib.range 1 number)); + capitalizeWord = word: let @@ -710,7 +715,10 @@ in # Virtual Desktops (lib.mkIf (cfg.kwin.virtualDesktops.number != null) { - Desktops.Number = cfg.kwin.virtualDesktops.number; + Desktops = lib.mkMerge [ + { Number = cfg.kwin.virtualDesktops.number; } + (virtualDesktopIdAttrs cfg.kwin.virtualDesktops.number) + ]; }) (lib.mkIf (cfg.kwin.virtualDesktops.rows != null) { Desktops.Rows = cfg.kwin.virtualDesktops.rows; @@ -718,6 +726,7 @@ in (lib.mkIf (cfg.kwin.virtualDesktops.names != null) { Desktops = lib.mkMerge [ { Number = builtins.length cfg.kwin.virtualDesktops.names; } + (virtualDesktopIdAttrs (builtins.length cfg.kwin.virtualDesktops.names)) (virtualDesktopNameAttrs cfg.kwin.virtualDesktops.names) ]; }) From 88ca377ff58b5c30a2879745829842554d4b21d5 Mon Sep 17 00:00:00 2001 From: Heitor Augusto Date: Sat, 30 Nov 2024 19:26:29 -0300 Subject: [PATCH 6/6] feat(workspace): add wallpaperBackground option (#427) --- modules/apps/okular.nix | 2 +- modules/kwin.nix | 7 ++- modules/widgets/icon-tasks.nix | 4 +- modules/widgets/plasmusic-toolbar.nix | 4 +- modules/workspace.nix | 65 +++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 9 deletions(-) diff --git a/modules/apps/okular.nix b/modules/apps/okular.nix index ebf1ecf8..e2307205 100644 --- a/modules/apps/okular.nix +++ b/modules/apps/okular.nix @@ -154,7 +154,7 @@ with lib.types; # Change to black & white colors (see options below) "BlackWhite" # Invert lightness but leave hue and saturation - "InvertLightness" + "InvertLightness" # Like InvertLightness, but slightly more contrast "InvertLumaSymmetric" # Like InvertLightness, but much more contrast diff --git a/modules/kwin.nix b/modules/kwin.nix index 42a93998..a2016f38 100644 --- a/modules/kwin.nix +++ b/modules/kwin.nix @@ -56,10 +56,13 @@ let names: builtins.listToAttrs (lib.imap1 (i: v: (lib.nameValuePair "Name_${builtins.toString i}" v)) names); - virtualDesktopIdAttrs = number: - builtins.listToAttrs (map (i: (lib.nameValuePair "Id_${builtins.toString i}" "Desktop_${builtins.toString i}")) (lib.range 1 number)); + builtins.listToAttrs ( + map (i: (lib.nameValuePair "Id_${builtins.toString i}" "Desktop_${builtins.toString i}")) ( + lib.range 1 number + ) + ); capitalizeWord = word: diff --git a/modules/widgets/icon-tasks.nix b/modules/widgets/icon-tasks.nix index bdb342bd..ae12f288 100644 --- a/modules/widgets/icon-tasks.nix +++ b/modules/widgets/icon-tasks.nix @@ -244,9 +244,7 @@ in ... }: { - name = if iconsOnly - then "org.kde.plasma.icontasks" - else "org.kde.plasma.taskmanager"; + name = if iconsOnly then "org.kde.plasma.icontasks" else "org.kde.plasma.taskmanager"; config = lib.recursiveUpdate { General = lib.filterAttrs (_: v: v != null) { launchers = launchers; diff --git a/modules/widgets/plasmusic-toolbar.nix b/modules/widgets/plasmusic-toolbar.nix index 304f2333..5f7413d6 100644 --- a/modules/widgets/plasmusic-toolbar.nix +++ b/modules/widgets/plasmusic-toolbar.nix @@ -263,9 +263,7 @@ in if source == null then { } else if source == "auto" then - { - choosePlayerAutomatically = true; - } + { choosePlayerAutomatically = true; } else { choosePlayerAutomatically = false; diff --git a/modules/workspace.nix b/modules/workspace.nix index 761b89ee..4e37f333 100644 --- a/modules/workspace.nix +++ b/modules/workspace.nix @@ -34,6 +34,23 @@ let }; }; + wallpaperBackgroundType = lib.types.submodule { + options = { + color = lib.mkOption { + type = with lib.types; nullOr str; + default = null; + example = "219,99,99"; + description = "Background color to use"; + }; + blur = lib.mkOption { + type = with lib.types; nullOr bool; + default = null; + example = true; + description = "Whether to blur the background"; + }; + }; + }; + anyThemeSet = ( cfg.workspace.theme != null || cfg.workspace.colorScheme != null @@ -191,6 +208,15 @@ in ''; }; + wallpaperBackground = lib.mkOption { + type = lib.types.nullOr wallpaperBackgroundType; + default = null; + example = { + blur = true; + }; + description = "How to handle wallpaper background when there is empty space."; + }; + soundTheme = lib.mkOption { type = with lib.types; nullOr str; default = null; @@ -282,6 +308,15 @@ in plasma.workspace.windowDecorations.theme or none. ''; } + { + assertion = ( + cfg.workspace.wallpaperBackground == null + || ( + cfg.workspace.wallpaperBackground.blur == null || cfg.workspace.wallpaperBackground.color == null + ) + ); + message = "programs.plasma.wallpaperBackground can only have a color or be blurred."; + } ]; warnings = ( if @@ -448,6 +483,21 @@ in toString wallpaperFillModeTypes.${cfg.workspace.wallpaperFillMode} }");'' } + ${ + lib.optionalString + (cfg.workspace.wallpaperBackground != null || cfg.workspace.wallpaperBackground != { }) + ''desktop.writeConfig("${ + if cfg.workspace.wallpaperBackground ? blur && cfg.workspace.wallpaperBackground.blur != null then + "Blur" + else + "Color" + }", "${ + if cfg.workspace.wallpaperBackground ? blur && cfg.workspace.wallpaperBackground.blur != null then + lib.boolToString cfg.workspace.wallpaperBackground.blur + else + cfg.workspace.wallpaperBackground.color + }");'' + } } ''; priority = 3; @@ -493,6 +543,21 @@ in toString wallpaperFillModeTypes.${cfg.workspace.wallpaperFillMode} }");'' } + ${ + lib.optionalString + (cfg.workspace.wallpaperBackground != null || cfg.workspace.wallpaperBackground != { }) + ''desktop.writeConfig("${ + if cfg.workspace.wallpaperBackground ? blur && cfg.workspace.wallpaperBackground.blur != null then + "Blur" + else + "Color" + }", "${ + if cfg.workspace.wallpaperBackground ? blur && cfg.workspace.wallpaperBackground.blur != null then + lib.boolToString cfg.workspace.wallpaperBackground.blur + else + cfg.workspace.wallpaperBackground.color + }");'' + } } ''; priority = 3;