This repository has no description
0

Configure Feed

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

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