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.5 kB 67 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 # it’s a file 25 26 # strip possible protocol 27 FILE=''${FILE#file://} 28 mime=''$(file -E --brief --mime-type "$FILE") \ 29 || (echo "$mime" 1>&2; exit 1) 30 # ^ echo the error message of file 31 ;; 32 esac 33 34 case "$mime" in 35 special/mailaddress) 36 alacritty --execute vim "$FILE" ;; 37 text/html) 38 firefox-devedition "$FILE" ;; 39 text/xml) 40 firefox-devedition "$FILE" ;; 41 text/*) 42 alacritty --execute vim "$FILE" ;; 43 image/*) 44 nsxiv "$FILE" ;; 45 application/x-bittorrent) 46 env DISPLAY=:0 transgui "$FILE" ;; 47 application/pdf) 48 zathura "$FILE" ;; 49 inode/directory) 50 alacritty --execute mc "$FILE" ;; 51 inode/symlink) 52 exec "$0" "$(realpath "$FILE")" ;; 53 audio/*) 54 mpv "$FILE" ;; 55 video/*) 56 mpv "$FILE" ;; 57 *) 58 echo $TERM >> /tmp/xdg.debug 59 # open dmenu and ask for program to open with 60 runner=$({ IFS=:; ls -H $PATH; } | sort | dmenu) 61 exec $runner "$FILE";; 62 esac 63 ''; 64in 65{ 66 environment.systemPackages = [ xdg-open ]; 67}