This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / 2configs / xdg-open.nix
1.6 kB 71 lines
1{ pkgs, ... }: 2let 3 4 xdg-open = pkgs.writeBashBin "xdg-open" '' 5 set -xe 6 FILE="$1" 7 PATH=/run/current-system/sw/bin 8 mime= 9 10 case "$FILE" in 11 http://*|https://*) 12 mime=text/html 13 ;; 14 mailto:*) 15 mime=special/mailaddress 16 ;; 17 magnet:*) 18 mime=application/x-bittorrent 19 ;; 20 irc:*) 21 mime=x-scheme-handler/irc 22 ;; 23 "") 24 echo "empty file" 1>&2 25 exit 0 26 ;; 27 *) 28 # it’s a file 29 30 # strip possible protocol 31 FILE=''${FILE#file://} 32 mime=''$(file -E --brief --mime-type "$FILE") \ 33 || (echo "$mime" 1>&2; exit 1) 34 # ^ echo the error message of file 35 ;; 36 esac 37 38 case "$mime" in 39 special/mailaddress) 40 alacritty --execute vim "$FILE" ;; 41 text/html) 42 firefox "$FILE" ;; 43 text/xml) 44 firefox "$FILE" ;; 45 text/*) 46 alacritty --execute vim "$FILE" ;; 47 image/*) 48 nsxiv "$FILE" ;; 49 application/x-bittorrent) 50 env DISPLAY=:0 transgui "$FILE" ;; 51 application/pdf) 52 zathura "$FILE" ;; 53 inode/directory) 54 alacritty --execute mc "$FILE" ;; 55 inode/symlink) 56 exec "$0" "$(realpath "$FILE")" ;; 57 audio/*) 58 mpv "$FILE" ;; 59 video/*) 60 mpv "$FILE" ;; 61 *) 62 echo $TERM >> /tmp/xdg.debug 63 # open dmenu and ask for program to open with 64 runner=$({ IFS=:; ls -H $PATH; } | sort | dmenu) 65 exec $runner "$FILE";; 66 esac 67 ''; 68in 69{ 70 environment.systemPackages = [ xdg-open ]; 71}