modules/desktop: add fake UI for Helix
This commit is contained in:
parent
b33fd034a1
commit
06050464d7
2 changed files with 59 additions and 0 deletions
|
@ -8,6 +8,7 @@ in {
|
|||
./package-sets.nix
|
||||
./nixpak-tricks.nix
|
||||
./hidden-apps.nix
|
||||
./helix-desktop.nix
|
||||
];
|
||||
|
||||
services.xserver = {
|
||||
|
|
58
modules/desktop/helix-desktop.nix
Normal file
58
modules/desktop/helix-desktop.nix
Normal file
|
@ -0,0 +1,58 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
let
|
||||
helixDesktop = pkgs.makeDesktopItem {
|
||||
name = "net.privatevoid.HelixDesktop";
|
||||
desktopName = "Helix";
|
||||
comment = "Helix Editor";
|
||||
mimeTypes = [
|
||||
"text/plain"
|
||||
"application/x-zerosize"
|
||||
"inode/directory"
|
||||
];
|
||||
inherit icon;
|
||||
tryExec = "hx";
|
||||
exec = ''${hxOpenHandler} %F'';
|
||||
};
|
||||
|
||||
icon = pkgs.fetchurl {
|
||||
name = "helix-logo.svg";
|
||||
url = "https://raw.githubusercontent.com/helix-editor/helix/d1a4bd876b3ae646693c0905d7f29b636e2e5033/logo.svg";
|
||||
sha256 = "sha256-1XBrlGbCfkfYhIZuQ9eDBgDoohup/gQ9VZynEerUqcY=";
|
||||
};
|
||||
|
||||
hxOpenHandler = pkgs.writeShellScript "hx-open-handler" ''
|
||||
isDir () { test -d "$1"; }
|
||||
isFile () { test -f "$1"; }
|
||||
findAnyDir () {
|
||||
for f in "$@"; do
|
||||
if test -d "$f"; then
|
||||
echo "$f"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
if [[ "$#" == 0 ]]; then
|
||||
exec blackbox -w "$HOME" -c hx
|
||||
elif [[ "$#" == 1 ]]; then
|
||||
isDir "$1" && exec blackbox -w "$1" -c "hx ."
|
||||
isFile "$1" && exec blackbox -w "$(dirname "$1")" -c "hx '$1'"
|
||||
else
|
||||
firstDir="$(findAnyDir "$@")"
|
||||
findAnyDirStatus="$?"
|
||||
if [[ "$findAnyDirStatus" == 0 ]]; then
|
||||
exec blackbox -w "$firstDir" -c "hx ."
|
||||
else
|
||||
# magic: find common base directory
|
||||
workDir="$(dirname "$@" | sed -e 'N;s/^\(.*\).*\n\1.*$/\1\n\1/;D')"
|
||||
args=("$@")
|
||||
exec blackbox -w "$workDir" -c "hx ''${args[*]@Q}"
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
in
|
||||
|
||||
{
|
||||
environment.systemPackages = [ helixDesktop ];
|
||||
}
|
Loading…
Reference in a new issue