This repository has no description
0

Configure Feed

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

superconfig / configs / xdg-open.nix
1.5 kB 69 lines
1{ pkgs, ... }: 2let 3 4 xdg-open = pkgs.writers.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/pdf) 50 zathura "$FILE" ;; 51 inode/directory) 52 alacritty --execute mc "$FILE" ;; 53 inode/symlink) 54 exec "$0" "$(realpath "$FILE")" ;; 55 audio/*) 56 mpv "$FILE" ;; 57 video/*) 58 mpv "$FILE" ;; 59 *) 60 echo $TERM >> /tmp/xdg.debug 61 # open dmenu and ask for program to open with 62 runner=$({ IFS=:; ls -H $PATH; } | sort | dmenu) 63 exec $runner "$FILE";; 64 esac 65 ''; 66in 67{ 68 environment.systemPackages = [ xdg-open ]; 69}