diff --git a/home/citadel.nix b/home/citadel.nix index 02d798a..c6efed7 100644 --- a/home/citadel.nix +++ b/home/citadel.nix @@ -14,6 +14,7 @@ ./common/optional/notes.nix ./common/optional/yazi.nix ./common/optional/desktop/common/kodi.nix + ./common/optional/desktop/common/xdg ]; home.packages = [ diff --git a/home/common/optional/desktop/common/xdg/default.nix b/home/common/optional/desktop/common/xdg/default.nix new file mode 100644 index 0000000..e0a44a2 --- /dev/null +++ b/home/common/optional/desktop/common/xdg/default.nix @@ -0,0 +1,67 @@ +{pkgs, ...}: +{ + imports = [./scripts.nix]; + + + xdg.desktopEntries = { + firefox = { + name = "Firefox"; + exec = "${pkgs.firefox}/bin/firefox"; + }; + zathura = { + name = "Zathura"; + exec = "${pkgs.zathura}/bin/zathura"; + terminal = false; + mimeType = ["application/pdf"]; + }; + nsxiv-wrapper = { + name = "Nsxiv-wrapper"; + # exec = "nsxiv-wrapper %f"; + exec = "st -c xdg-open-nsxiv -T st-float -g 150x50 -e nsxiv %F"; + terminal = false; + mimeType = ["image/*"]; + }; + nvim-wrapper = { + name = "Nvim-wrapper"; + exec = "st -c xdg-open-nvim -T st-float -g 150x50 -e nvim %F"; + terminal = false; + mimeType = ["text/*"]; + }; + mpv-wrapper = { + name = "Mpv-wrapper"; + exec = "st -c xdg-open-mpv -T st-float -g 150x50 -e mpv %F"; + terminal = false; + mimeType = ["video/*"]; + }; + }; + + xdg.mimeApps = { + enable = true; + defaultApplications = { + "application/pdf" = "zathura.desktop"; + + # text + "text/html" = "firefox.desktop"; + "text/plain" = "nvim-wrapper.desktop"; + + # images + "image/jpeg" = "nsxiv-wrapper.desktop"; + "image/jpg" = "nsxiv-wrapper.desktop"; + "image/png" = "nsxiv-wrapper.desktop"; + "image/tiff" = "nsxiv-wrapper.desktop"; + "image/gif" = "nsxiv-wrapper.desktop"; + "image/heic" = "nsxiv-wrapper.desktop"; + "image/bmp" = "nsxiv-wrapper.desktop"; + "image/webp" = "nsxiv-wrapper.desktop"; + + # video + "video/mp4" = "mpv-wrapper.desktop"; + "video/mpeg" = "mpv-wrapper.desktop"; + + "x-scheme-handler/http" = "firefox.desktop"; + "x-scheme-handler/https" = "firefox.desktop"; + "x-scheme-handler/about" = "firefox.desktop"; + "x-scheme-handler/unknown" = "firefox.desktop"; + }; + }; +} diff --git a/home/common/optional/desktop/common/xdg/scripts.nix b/home/common/optional/desktop/common/xdg/scripts.nix new file mode 100644 index 0000000..6dac97b --- /dev/null +++ b/home/common/optional/desktop/common/xdg/scripts.nix @@ -0,0 +1,17 @@ +{pkgs, ...}: { + home.packages = with pkgs; [ + (writeShellScriptBin "nsxiv-wrapper" '' + # Script to open image files with nsxiv + monitor_name=$(get-focused-monitor) + monitor_info=$(${xorg.xrandr}/bin/xrandr | grep "$monitor_name") + + width=$(echo $monitor_info | grep -oP '\d+x\d+' | cut -dx -f1) + height=$(echo $monitor_info | grep -oP '\d+x\d+' | cut -dx -f2) + + scale_width=$(( $width/4 + $width/2 )) + scale_height=$(( $height/4 + $height/2 )) + + echo "$1" | ${nsxiv}/bin/nsxiv -ioq -g "$scale_width"x"$scale_height" -N float + '') + ]; +} diff --git a/home/common/optional/desktop/dwm/scripts/clipboard-recall.nix b/home/common/optional/desktop/dwm/scripts/clipboard-recall.nix index a19e923..7e522d7 100644 --- a/home/common/optional/desktop/dwm/scripts/clipboard-recall.nix +++ b/home/common/optional/desktop/dwm/scripts/clipboard-recall.nix @@ -53,7 +53,7 @@ (writeShellScriptBin "clipboard-image-recall" '' # Script to view and select and output images in image clipboard dir to clipboard. monitor_name=$(get-focused-monitor) - monitor_info=$(xrandr | grep "$monitor_name") + monitor_info=$(${xorg.xrandr}/bin/xrandr | grep "$monitor_name") width=$(echo $monitor_info | grep -oP '\d+x\d+' | cut -dx -f1) height=$(echo $monitor_info | grep -oP '\d+x\d+' | cut -dx -f2) @@ -68,7 +68,7 @@ filesdir="$(find $1 -type f -printf '%T@ %p\n' | sort -rn | cut -d ' ' -f 2-)" [ "$filesdir" == "" ] && notify-send -t 1000 "Clipboard Recall" "No images in directory" && exit 1 - output="$(echo "$filesdir" | ${nsxiv}/bin/nsxiv -tioq -g "$scale_width"x"$scale_height" -N nsxiv-float )" + output="$(echo "$filesdir" | ${nsxiv}/bin/nsxiv -tioq -g "$scale_width"x"$scale_height" -N float )" num_lines=$( echo "$output" | wc -l) if [ "$num_lines" -gt 1 ]; then diff --git a/home/common/optional/desktop/dwm/scripts/get-focused-monitor.nix b/home/common/optional/desktop/dwm/scripts/get-focused-monitor.nix index 3de584d..6dab10d 100644 --- a/home/common/optional/desktop/dwm/scripts/get-focused-monitor.nix +++ b/home/common/optional/desktop/dwm/scripts/get-focused-monitor.nix @@ -3,7 +3,7 @@ home.packages = with pkgs; [ (writeShellScriptBin "get-focused-monitor" '' # get the current cursor location into X and Y variables - eval $(xdotool getmouselocation --shell) + eval $(${xdotool}/bin/xdotool getmouselocation --shell) # compare mouse location to monitor coordinates while IFS= read -r line; do diff --git a/home/users/sam/default.nix b/home/users/sam/default.nix index 76f0674..6f8a99c 100644 --- a/home/users/sam/default.nix +++ b/home/users/sam/default.nix @@ -1,4 +1,9 @@ -{outputs, ...}: { +{ + outputs, + ... +}: + +{ home.username = "sam"; home.homeDirectory = "/home/sam"; diff --git a/hosts/citadel/default.nix b/hosts/citadel/default.nix index 3426714..a563781 100644 --- a/hosts/citadel/default.nix +++ b/hosts/citadel/default.nix @@ -56,6 +56,7 @@ in { ../common/optional/nix-ld.nix ../common/optional/gaming.nix ../common/optional/powersave.nix + ../common/optional/restic-backup.nix ]; boot = { @@ -180,6 +181,8 @@ in { ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="on" ''; + programs.fuse.userAllowOther = true; + networking = { hostName = "citadel"; networkmanager.enable = true; diff --git a/hosts/common/optional/dwm.nix b/hosts/common/optional/dwm.nix index ec8bf78..3114741 100644 --- a/hosts/common/optional/dwm.nix +++ b/hosts/common/optional/dwm.nix @@ -15,8 +15,8 @@ # src = /home/sam/.local/share/src/dwm; src = pkgs.fetchgit { url = "https://git.bitlab21.com/sam/dwm"; - rev = "3e0601b29d879e589703239e064f0baaabb3474b"; - sha256 = "sha256-7Hq0vo6YnXKhEUdKjvaAeKodq2l8wwJRzCYJfdHDNMQ="; + rev = "26c82bae50ed580f651fd8316d9b162620872035"; + sha256 = "sha256-Qx71t1d7RMVaWKIJ71SPIF49+jjhwN7xI2ZubAoHO8E="; }; }; };