From f6832333dcc7c156099764d12a3bca090164dbda Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 24 Jun 2024 00:03:23 +0200 Subject: [PATCH 1/5] Add wl-clip-persist --- home/services/default.nix | 1 + home/services/wl-clip-persist.nix | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 home/services/wl-clip-persist.nix diff --git a/home/services/default.nix b/home/services/default.nix index 9799edc..68ec314 100644 --- a/home/services/default.nix +++ b/home/services/default.nix @@ -1,5 +1,6 @@ _: { imports = [ ./dunst.nix + ./wl-clip-persist.nix ]; } diff --git a/home/services/wl-clip-persist.nix b/home/services/wl-clip-persist.nix new file mode 100644 index 0000000..fa15668 --- /dev/null +++ b/home/services/wl-clip-persist.nix @@ -0,0 +1,28 @@ +{ + osConfig, + pkgs, + lib, + ... +}: let + inherit (lib) mkIf; + + cfgIsWayland = osConfig.myOptions.home-manager.wms.isWayland; +in { + config = mkIf cfgIsWayland { + systemd.user.services."wl-clip-persist" = { + Unit = { + Description = "wl-clip-persist (Persist clipboard entries on wayland even after the application gets closed.)"; + After = [ "graphical-session.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + Type = "simple"; + Restart = "on-failure"; + ExecStart = "${pkgs.wl-clip-persist}/bin/wl-clip-persist --clipboard regular --reconnect-tries 1 --selection-size-limit 1048576"; + }; + + Install.WantedBy = [ "graphical-session.target" ]; + }; + }; +} From a5548c5b8c87828763ee39e10bad6f6c991aaa55 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 24 Jun 2024 00:03:39 +0200 Subject: [PATCH 2/5] Rework mime types --- home/programs/xdg/mime-apps.nix | 172 ++++++++++++++++++++++++++++---- 1 file changed, 154 insertions(+), 18 deletions(-) diff --git a/home/programs/xdg/mime-apps.nix b/home/programs/xdg/mime-apps.nix index 4c5ae71..2edeb70 100644 --- a/home/programs/xdg/mime-apps.nix +++ b/home/programs/xdg/mime-apps.nix @@ -9,7 +9,7 @@ in { browser = "firefox.desktop"; textEditor = browser; # nvim doesn't work properly with xdg-open, just use the browser emailClient = browser; - pdfViewer = browser; # TODO: consider zathura (org.pwmt.zathura.desktop.desktop) + documentViewer = browser; # TODO: consider zathura (org.pwmt.zathura.desktop.desktop) fileManager = "pcmanfm-qt.desktop"; # TODO: change archiveManager = "org.kde.ark.desktop"; imageViewer = @@ -18,10 +18,10 @@ in { else if cfg.applications.nomacs.enable then "org.nomacs.ImageLounge.desktop" else browser; - videoPlayer = "mpv.desktop"; - audioPlayer = "mpv.desktop"; + mediaPlayer = "mpv.desktop"; associations = { + # Browser "text/html" = [browser]; "x-scheme-handler/http" = [browser]; "x-scheme-handler/https" = [browser]; @@ -30,36 +30,172 @@ in { "application/x-extension-htm" = [browser]; "application/x-extension-html" = [browser]; "application/x-extension-shtml" = [browser]; - "application/xhtml+xml" = [browser]; "application/x-extension-xhtml" = [browser]; "application/x-extension-xht" = [browser]; + "application/xhtml+xml" = [browser]; + "application/xhtml_xml" = [browser]; - "application/pdf" = [pdfViewer]; - "x-scheme-handler/mailto" = [emailClient]; + # Image viewer + "image/*" = [imageViewer]; # wildcard associations don't work everywhere + "image/bmp" = [imageViewer]; + "image/gif" = [imageViewer]; + "image/jpeg" = [imageViewer]; + "image/jpg" = [imageViewer]; + "image/png" = [imageViewer]; + "image/tiff" = [imageViewer]; + "image/x-bmp" = [imageViewer]; + "image/x-pcx" = [imageViewer]; + "image/x-tga" = [imageViewer]; + "image/x-portable-pixmap" = [imageViewer]; + "image/x-portable-bitmap" = [imageViewer]; + "image/x-portable-greymap" = [imageViewer]; + "image/x-targa" = [imageViewer]; + "image/svg+xml" = [imageViewer]; + "image/svg_xml" = [imageViewer]; + # Media Player (video + audio) + "video/*" = [mediaPlayer]; # wildcard associations don't work everywhere + "audio/*" = [mediaPlayer]; # -||- + "video/mpeg" = [mediaPlayer]; + "video/x-mpeg2" = [mediaPlayer]; + "video/x-mpeg3" = [mediaPlayer]; + "video/mp4v-es" = [mediaPlayer]; + "video/x-m4v" = [mediaPlayer]; + "video/mp4" = [mediaPlayer]; + "video/divx" = [mediaPlayer]; + "video/vnd.divx" = [mediaPlayer]; + "video/msvideo" = [mediaPlayer]; + "video/x-msvideo" = [mediaPlayer]; + "video/ogg" = [mediaPlayer]; + "video/quicktime" = [mediaPlayer]; + "video/vnd.rn-realvideo" = [mediaPlayer]; + "video/x-avi" = [mediaPlayer]; + "video/avi" = [mediaPlayer]; + "video/x-flic" = [mediaPlayer]; + "video/fli" = [mediaPlayer]; + "video/x-flc" = [mediaPlayer]; + "video/flv" = [mediaPlayer]; + "video/x-flv" = [mediaPlayer]; + "video/x-theora" = [mediaPlayer]; + "video/x-theora+ogg" = [mediaPlayer]; + "video/x-matroska" = [mediaPlayer]; + "video/mkv" = [mediaPlayer]; + "video/webm" = [mediaPlayer]; + "video/x-ogm" = [mediaPlayer]; + "video/x-ogm+ogg" = [mediaPlayer]; + "video/dv" = [mediaPlayer]; + "video/mp2t" = [mediaPlayer]; + "video/vnd.mpegurl" = [mediaPlayer]; + "video/3gp" = [mediaPlayer]; + "video/3gpp" = [mediaPlayer]; + "video/3gpp2" = [mediaPlayer]; + + "application/x-cue" = [mediaPlayer]; + "application/vnd.ms-asf" = [mediaPlayer]; + "application/x-matroska" = [mediaPlayer]; + "application/x-ogm" = [mediaPlayer]; + "application/x-ogm-audio" = [mediaPlayer]; + "application/x-ogm-video" = [mediaPlayer]; + "application/x-shorten" = [mediaPlayer]; + "application/x-mpegurl" = [mediaPlayer]; + "application/vnd.apple.mpegurl" = [mediaPlayer]; + "application/ogg" = [mediaPlayer]; + "application/x-ogg" = [mediaPlayer]; + "application/mxf" = [mediaPlayer]; + "application/sdp" = [mediaPlayer]; + "application/smil" = [mediaPlayer]; + "application/x-smil" = [mediaPlayer]; + "application/streamingmedia" = [mediaPlayer]; + "application/x-streamingmedia" = [mediaPlayer]; + "application/vnd.rn-realmedia" = [mediaPlayer]; + "application/vnd.rn-realmedia-vbr" = [mediaPlayer]; + "application/x-extension-m4a" = [mediaPlayer]; + + "audio/x-matroska" = [mediaPlayer]; + "audio/webm" = [mediaPlayer]; + "audio/vorbis" = [mediaPlayer]; + "audio/x-vorbis" = [mediaPlayer]; + "audio/x-vorbis+ogg" = [mediaPlayer]; + "audio/x-shorten" = [mediaPlayer]; + "audio/x-ape" = [mediaPlayer]; + "audio/x-wavpack" = [mediaPlayer]; + "audio/x-tta" = [mediaPlayer]; + "audio/AMR" = [mediaPlayer]; + "audio/ac3" = [mediaPlayer]; + "audio/eac3" = [mediaPlayer]; + "audio/amr-wb" = [mediaPlayer]; + "audio/flac" = [mediaPlayer]; + "audio/mp4" = [mediaPlayer]; + "audio/x-pn-au" = [mediaPlayer]; + "audio/3gpp" = [mediaPlayer]; + "audio/3gpp2" = [mediaPlayer]; + "audio/dv" = [mediaPlayer]; + "audio/opus" = [mediaPlayer]; + "audio/x-ms-asf" = [mediaPlayer]; + "audio/vnd.dts" = [mediaPlayer]; + "audio/vnd.dts.hd" = [mediaPlayer]; + "audio/x-adpcm" = [mediaPlayer]; + "audio/m3u" = [mediaPlayer]; + "audio/aac" = [mediaPlayer]; + "audio/x-aac" = [mediaPlayer]; + "audio/vnd.dolby.heaac.1" = [mediaPlayer]; + "audio/vnd.dolby.heaac.2" = [mediaPlayer]; + "audio/aiff" = [mediaPlayer]; + "audio/x-aiff" = [mediaPlayer]; + "audio/m4a" = [mediaPlayer]; + "audio/x-m4a" = [mediaPlayer]; + "audio/mp1" = [mediaPlayer]; + "audio/x-mp1" = [mediaPlayer]; + "audio/mp2" = [mediaPlayer]; + "audio/x-mp2" = [mediaPlayer]; + "audio/mp3" = [mediaPlayer]; + "audio/x-mp3" = [mediaPlayer]; + "audio/mpeg" = [mediaPlayer]; + "audio/mpeg2" = [mediaPlayer]; + "audio/mpeg3" = [mediaPlayer]; + "audio/mpegurl" = [mediaPlayer]; + "audio/x-mpegurl" = [mediaPlayer]; + "audio/mpg" = [mediaPlayer]; + "audio/x-mpg" = [mediaPlayer]; + "audio/rn-mpeg" = [mediaPlayer]; + "audio/musepack" = [mediaPlayer]; + "audio/x-musepack" = [mediaPlayer]; + "audio/ogg" = [mediaPlayer]; + "audio/scpls" = [mediaPlayer]; + "audio/x-scpls" = [mediaPlayer]; + "audio/vnd.rn-realaudio" = [mediaPlayer]; + "audio/wav" = [mediaPlayer]; + "audio/x-pn-wav" = [mediaPlayer]; + "audio/x-pn-windows-pcm" = [mediaPlayer]; + "audio/x-realaudio" = [mediaPlayer]; + "audio/x-pn-realaudio" = [mediaPlayer]; + "audio/x-ms-wma" = [mediaPlayer]; + "audio/x-pls" = [mediaPlayer]; + "audio/x-wav" = [mediaPlayer]; + + # Document Viewer + "application/pdf" = [documentViewer]; + "application/epub" = [documentViewer]; + "application/djvu" = [documentViewer]; + "application/mobi" = [documentViewer]; + + # File & archive manager(s) "inode/directory" = [fileManager]; "application/zip" = [archiveManager]; "application/x-xz-compressed-tar" = [archiveManager]; - "image/*" = [imageViewer]; - "audio/*" = [audioPlayer]; - "video/*" = [videoPlayer]; - - # The wildcard associations don't work everywhere, so we - # still need specific ones - "image/jpeg" = [imageViewer]; - "image/png" = [imageViewer]; - "image/svg+xml" = [imageViewer]; - "image/gif" = [imageViewer]; - "video/mp4" = [videoPlayer]; - + # Plain-text "text/plain" = [textEditor]; "application/json" = [textEditor]; + # Application specific schemes "x-scheme-handler/spotify" = ["spotify.desktop"]; "x-scheme-handler/tg" = ["telegramdesktop.desktop"]; "x-scheme-handler/discord" = ["vesktop.desktop"]; "x-scheme-handler/msteams" = ["teams.desktop"]; # I need it for school, don't judge me + + # Misc + "x-scheme-handler/mailto" = [emailClient]; }; in { enable = true; From 760af68c1dd68513894853539b980ba9ce90c530 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 24 Jun 2024 00:15:19 +0200 Subject: [PATCH 3/5] Remove wl-clip-persist (breaks clipboard) When wl-clip-persist service is running, it seems that copying from xwayland applications becomes impossible. This is way too big of a bug to justify the benefit of this service. --- home/services/default.nix | 1 - home/services/wl-clip-persist.nix | 28 ---------------------------- 2 files changed, 29 deletions(-) delete mode 100644 home/services/wl-clip-persist.nix diff --git a/home/services/default.nix b/home/services/default.nix index 68ec314..9799edc 100644 --- a/home/services/default.nix +++ b/home/services/default.nix @@ -1,6 +1,5 @@ _: { imports = [ ./dunst.nix - ./wl-clip-persist.nix ]; } diff --git a/home/services/wl-clip-persist.nix b/home/services/wl-clip-persist.nix deleted file mode 100644 index fa15668..0000000 --- a/home/services/wl-clip-persist.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ - osConfig, - pkgs, - lib, - ... -}: let - inherit (lib) mkIf; - - cfgIsWayland = osConfig.myOptions.home-manager.wms.isWayland; -in { - config = mkIf cfgIsWayland { - systemd.user.services."wl-clip-persist" = { - Unit = { - Description = "wl-clip-persist (Persist clipboard entries on wayland even after the application gets closed.)"; - After = [ "graphical-session.target" ]; - PartOf = [ "graphical-session.target" ]; - }; - - Service = { - Type = "simple"; - Restart = "on-failure"; - ExecStart = "${pkgs.wl-clip-persist}/bin/wl-clip-persist --clipboard regular --reconnect-tries 1 --selection-size-limit 1048576"; - }; - - Install.WantedBy = [ "graphical-session.target" ]; - }; - }; -} From 703ee70a4754995bf235ed9fb5318562207f76af Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 24 Jun 2024 00:27:54 +0200 Subject: [PATCH 4/5] Update bluetooth config --- hosts/herugrim/default.nix | 2 +- hosts/voyager/default.nix | 2 +- options/device/hardware.nix | 21 +++++++++++++++++++-- system/shared/hardware/bluetooth.nix | 6 +++--- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/hosts/herugrim/default.nix b/hosts/herugrim/default.nix index 5872cd2..894c92d 100644 --- a/hosts/herugrim/default.nix +++ b/hosts/herugrim/default.nix @@ -30,7 +30,6 @@ username = "itsdrike"; sound.enable = true; - bluetooth.enable = true; impermanence = { root = { @@ -61,6 +60,7 @@ cpu.type = "amd"; gpu.type = "hybrid-nvidia"; hasTPM = true; + bluetooth.enable = true; }; security = { diff --git a/hosts/voyager/default.nix b/hosts/voyager/default.nix index c83db29..8e17d6b 100644 --- a/hosts/voyager/default.nix +++ b/hosts/voyager/default.nix @@ -35,7 +35,6 @@ username = "itsdrike"; sound.enable = true; - bluetooth.enable = true; impermanence = { root = { @@ -115,6 +114,7 @@ cpu.type = "amd"; gpu.type = "amd"; hasTPM = true; + bluetooth.enable = true; }; security = { diff --git a/options/device/hardware.nix b/options/device/hardware.nix index 5b03a78..c097978 100644 --- a/options/device/hardware.nix +++ b/options/device/hardware.nix @@ -1,4 +1,5 @@ -{ lib, ... }: with lib; let +{ lib, ... }: let + inherit (lib) mkOption mkEnableOption types; in { options.myOptions.device = { @@ -34,9 +35,25 @@ in }; hasTPM = mkOption { - type = lib.types.bool; + type = types.bool; default = false; description = "Does this device have a TPM (Trusted Platform Module)?"; }; + + bluetooth = { + enable = mkEnableOption "bluetooth modules, drivers and configuration program(s)"; + powerOnBoot = mkOption { + type = types.bool; + default = false; + description = '' + Should bluetooth be powered on automatically during boot? + + This will worsen the battery life and is not recommended. Instead, you can + always turn bluetooth on manually once booted, when you need it. Unless you + have constant need for bluetooth / have some devices to connect to automatically + you, leave this off. + ''; + }; + }; }; } diff --git a/system/shared/hardware/bluetooth.nix b/system/shared/hardware/bluetooth.nix index f32fba8..a4ef4d1 100644 --- a/system/shared/hardware/bluetooth.nix +++ b/system/shared/hardware/bluetooth.nix @@ -6,14 +6,14 @@ }: let inherit (lib) mkIf; - sys = config.myOptions.system.bluetooth; + cfg = config.myOptions.device.bluetooth; in { - config = mkIf sys.enable { + config = mkIf cfg.enable { hardware.bluetooth = { enable = true; package = pkgs.bluez5-experimental; + powerOnBoot = cfg.powerOnBoot; #hsphfpd.enable = true; - powerOnBoot = true; disabledPlugins = ["sap"]; settings = { General = { From a38498eef2f570755372a9d15c673cb24fb62aac Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 24 Jun 2024 00:28:13 +0200 Subject: [PATCH 5/5] Credit spikespaz/dotfiles --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5fda9e2..c8e490c 100644 --- a/README.md +++ b/README.md @@ -16,4 +16,5 @@ My NixOS and home-manager flake This configuration was massively inspired by the following amazing projects: - (major inspiration) +- -