Skip to content

feat: declarative kickoff favorites - #694

Open
itzTheMeow wants to merge 1 commit into
nix-community:trunkfrom
itzTheMeow:kickoff-favorites
Open

itzTheMeow wants to merge 1 commit into
nix-community:trunkfrom
itzTheMeow:kickoff-favorites

Conversation

@itzTheMeow

Copy link
Copy Markdown

supersedes #642 - uses some of that methodology
closes #539
related: #376

This is my attempt at declarative kickoff favorites.
This is a program-wide module rather than a panel-specific override since it is difficult to determine the actual applet ID of each kickoff widget, so setting favorites will change all kickoff widget favorites and ordering to match.

Favorites are stored in the kactivitymanagerd database and its pretty trivial to edit them. This module adds 2 scripts.
The pre-boot script runs before plasmashell and kactivitymanagerd start, so it can modify the sqlite database to add/remove the pinned favorites.

It also edits the statsrc file with the correct ordering.
The applet ID for statsrc is parsed from the appletsrc file, meaning that file will have to exist at boot for the ordering to apply properly.
(i ran into this issue due to my impermanence setup, and had to persist the appletsrc file which led to #693)

This also means that on an edge case where someone drastically changes their panel configuration such that the kickoff widget IDs change, on the first login the ordering will not apply since the new panel won't be written to appletsrc until after the reconciliation. It seems kickoff defaults to a lexicographical ordering of the favorites in this case. Favorite ordering will correctly re-apply on next login.

There is a second fallback script that uses dbus to add/remove favorites, this is only ran if it is found that the database is out of sync. Really the only time this would happen is on a fresh install where the database does not exist yet when the initial reconciliation runs. The side-effect of this is that it requires plasmashell to be restarted to take effect.
I was running this dbus script on my machine for a couple of months before redoing this.

The wording in the module description is taken from the original #238 PR.

Tested this on my NixOS 26.05 machine with Plasma 6.6.6 and a full favorites menu.
Some of the planning and development was assisted by OpenCode (GLM 5.3 Flash)

@itzTheMeow

Copy link
Copy Markdown
Author

quick VM for testing:

{
  nixpkgs ? builtins.getFlake "github:NixOS/nixpkgs/nixos-unstable",
  home-manager ? builtins.getFlake "github:nix-community/home-manager",
}:
let
  system = "x86_64-linux";
in
(nixpkgs.lib.nixosSystem {
  inherit system;
  modules = [
    home-manager.nixosModules.home-manager
    (
      { modulesPath, ... }:
      {
        imports = [
          (modulesPath + "/profiles/qemu-guest.nix")
          (modulesPath + "/virtualisation/qemu-vm.nix")
        ];

        networking.hostName = "plasma-kickoff";

        fileSystems."/" = {
          device = "/dev/disk/by-label/nixos";
          fsType = "ext4";
          autoResize = true;
        };

        boot = {
          growPartition = true;
          loader.timeout = 5;
          kernelParams = [
            "console=ttyS0"
            "boot.shell_on_fail"
          ];
        };

        virtualisation = {
          memorySize = 4096;
          cores = 4;
        };

        services.xserver.enable = true;
        services.displayManager = {
          autoLogin = {
            enable = true;
            user = "fake";
          };
          defaultSession = "plasma";
          plasma-login-manager.enable = true;
        };
        services.desktopManager.plasma6.enable = true;
        security.sudo.wheelNeedsPassword = false;

        system.stateVersion = "26.05";
        users.users.fake = {
          createHome = true;
          isNormalUser = true;
          password = "password";
          group = "users";
          extraGroups = [ "wheel" ];
        };

        home-manager.users.fake = {
          home.stateVersion = "26.05";
          imports = [ ./modules ];

          programs.plasma = {
            enable = true;
            kickoff.favorites = [
              "applications:org.kde.konsole.desktop"
              "applications:org.kde.okular.desktop"
              "applications:org.kde.dolphin.desktop"
            ];
          };
        };
      }
    )
  ];
}).config.system.build.vm

meant to be placed at the root of the repo
run nix build -f kickoff-vm.nix && ./result/bin/run-plasma-kickoff-vm to start

first ever boot:
image
items are in incorrect order due to the database not existing on first boot, however all 3 pinned favorites are set

reboot the VM, items are now in the correct order:

image

you should be able to reorder or add/delete any random favorites and on logout/login or reboot they will appear correct again

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to declaratively add apps to favorite?

1 participant