Module to manage desktop shortcuts in chromium or brave?

Hi there, In Brave/Chromium, you can create a shortcut for a website (essentially a web wrapper), by going to menu > more tools > create shortcut. I like this over my current method as it takes care of the wmclass.

I was considering using this method for the first time to create my wrappers and then porting it to nix code.

This method creates a number of manifest files, desktop files, icons, etc, based on what appears to be a random string.

I wanted to see if anyone has by chance seen some sort of module someone may have already created, before I run down this rabbit hole.

Thanks.

1 Like

For anyone who lands here. I wrote a simple nix function which can then be used to create/install a "web app. Tested with Brave and chromium.

Now, it is slightly different (from my original question) in that it does not create an “app” in Brave, etc. (IE, you will not see it under brave://apps).

It should work with any browser that supports these cli flags:

${binary} --ozone-platform-hint=auto --force-dark-mode --enable-features=WebUIDarkMode --new-window --app="${url}"

At it’s core you can use it (as an example):

 # Import the makeDesktopApp function
  makeDesktopApp = pkgs.callPackage ../../../lib/cbb-webwrap { };

  githubApp = makeDesktopApp {
    name = "Github";
    url = "https://github.com/bashfulrobot/nixos";
    binary = "${pkgs.brave}/bin/brave";
    startupWMClass = "brave-github.com__bashfulrobot_nixos-Default";
    iconSizes = [ "32" "48" "64" "96" "128" "256" ];
    # iconSizes = [ "256" ]; # forcing large icon use
    iconPath = ./icons; # path to icons
  };

environment.systemPackages = [ githubApp.desktopItem ]
      ++ githubApp.icons;

From app to app the main thing to change is:

  • githubApp
  • name
  • startupWMClass
  • iconSizes

In theory, I should add “flags” to enable the options for dark mode rather than defaulting. But it fits my use case.

this is terrific, I am going to give in a try, thank you!

Sounds good.

Few Minor notes:

  • icons must already exist.
  • sizes must match file names of icons
  • you need to get the WM_CLASS to have proper alt tab icons. Can use looking glass on Gnome. If on Sway, you can look at my fish shell function which has the commands to get the appid/wmclass.

Here is how I defined a “github app”.
Here is how I defined an app for this discourse forum.