mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-04-30 12:19:11 +00:00
lib: add naive get XDG autostart file function
This commit is contained in:
parent
1451905a7f
commit
103753221b
28
lib/xdg.nix
28
lib/xdg.nix
@ -28,4 +28,32 @@ rec {
|
||||
*/
|
||||
getXdgDesktop = drv: name:
|
||||
"${drv}/share/applications/${name}.desktop";
|
||||
|
||||
/**
|
||||
Naively get the absolute path of an autostart file given a derivation and a
|
||||
name.
|
||||
|
||||
# Arguments
|
||||
|
||||
drv
|
||||
: The derivation.
|
||||
|
||||
name
|
||||
: The name of the `.desktop` file (without the `.desktop` extension).
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
getXdgDesktop :: Derivation -> String -> Path
|
||||
```
|
||||
|
||||
# Example
|
||||
|
||||
```nix
|
||||
getXdgDesktop pkgs.wezterm "org.wezfurlong.wezterm"
|
||||
=> /nix/store/$HASH-wezterm-org.wezterm.wezterm.desktop
|
||||
```
|
||||
*/
|
||||
getXdgAutostartFile = drv: name:
|
||||
"${drv}/etc/xdg/autostart/${name}.desktop";
|
||||
}
|
||||
|
@ -11,4 +11,15 @@ lib.runTests {
|
||||
expr = self.xdg.getXdgDesktop pkgs.hello "non-existing-desktop";
|
||||
expected = "${pkgs.hello}/share/applications/non-existing-desktop.desktop";
|
||||
};
|
||||
|
||||
testGetXdgAutostartFile = {
|
||||
expr = self.xdg.getXdgAutostartFile pkgs.valent "valent";
|
||||
expected = "${pkgs.valent}/etc/xdg/autostart/valent.desktop";
|
||||
};
|
||||
|
||||
# This should be a naive function so it should just naively get things.
|
||||
testGetXdgAutostartFile2 = {
|
||||
expr = self.xdg.getXdgAutostartFile pkgs.hello "non-existing-autostart";
|
||||
expected = "${pkgs.hello}/etc/xdg/autostart/non-existing-autostart.desktop";
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user