summaryrefslogtreecommitdiffstats
path: root/lass/2configs/xdg-open.nix
diff options
context:
space:
mode:
authorlassulus <git@lassul.us>2023-09-07 12:26:31 +0200
committerlassulus <git@lassul.us>2023-09-07 13:50:26 +0200
commitf55307fd73af235069744dd5155fda0bc73fe613 (patch)
treef048d7750a50e48493505a08784c96d07d291f89 /lass/2configs/xdg-open.nix
parent85ae348bf3f53125c8281669a32bf007dc0063be (diff)
lass: migrate away
Diffstat (limited to 'lass/2configs/xdg-open.nix')
-rw-r--r--lass/2configs/xdg-open.nix67
1 files changed, 0 insertions, 67 deletions
diff --git a/lass/2configs/xdg-open.nix b/lass/2configs/xdg-open.nix
deleted file mode 100644
index 02c551a2..00000000
--- a/lass/2configs/xdg-open.nix
+++ /dev/null
@@ -1,67 +0,0 @@
-{ config, pkgs, lib, ... }: with import <stockholm/lib>; let
-
- xdg-open-wrapper = pkgs.writeDashBin "xdg-open" ''
- exec ${xdg-open}/bin/xdg-open "$@" >> /tmp/xdg-debug.log 2>&1
- '';
-
- xdg-open = pkgs.writeBashBin "xdg-open" ''
- set -xe
- FILE="$1"
- PATH=/run/current-system/sw/bin
- mime=
-
- case "$FILE" in
- http://*|https://*)
- mime=text/html
- ;;
- mailto:*)
- mime=special/mailaddress
- ;;
- magnet:*)
- mime=application/x-bittorrent
- ;;
- irc:*)
- mime=x-scheme-handler/irc
- ;;
- *)
- # it’s a file
-
- # strip possible protocol
- FILE=''${FILE#file://}
- mime=''$(file -E --brief --mime-type "$FILE") \
- || (echo "$mime" 1>&2; exit 1)
- # ^ echo the error message of file
- ;;
- esac
-
- case "$mime" in
- special/mailaddress)
- alacritty --execute vim "$FILE" ;;
- text/html)
- firefox "$FILE" ;;
- text/xml)
- firefox "$FILE" ;;
- text/*)
- alacritty --execute vim "$FILE" ;;
- image/*)
- sxiv "$FILE" ;;
- application/x-bittorrent)
- env DISPLAY=:0 transgui "$FILE" ;;
- application/pdf)
- zathura "$FILE" ;;
- inode/directory)
- alacritty --execute mc "$FILE" ;;
- *)
- # open dmenu and ask for program to open with
- runner=$(print -rC1 -- ''${(ko)commands} | dmenu)
- exec $runner "$FILE";;
- esac
- '';
-in {
- environment.systemPackages = [ xdg-open-wrapper ];
-
- security.sudo.extraConfig = ''
- cr ALL=(lass) NOPASSWD: ${xdg-open}/bin/xdg-open *
- ff ALL=(lass) NOPASSWD: ${xdg-open}/bin/xdg-open *
- '';
-}