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