Add preference options

This commit is contained in:
ItsDrike 2024-06-24 21:12:59 +02:00
parent 32bebe0adc
commit 15ce6ea7d0
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
6 changed files with 228 additions and 212 deletions

View file

@ -7,6 +7,7 @@
inherit (lib) mkIf; inherit (lib) mkIf;
cfg = osConfig.myOptions.home-manager.programs.file-managers.pcmanfm-qt; cfg = osConfig.myOptions.home-manager.programs.file-managers.pcmanfm-qt;
cfgPreferences = osConfig.myOptions.home-manager.preferences;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = with pkgs; [ lxqt.pcmanfm-qt ]; home.packages = with pkgs; [ lxqt.pcmanfm-qt ];
@ -96,14 +97,14 @@ in {
}; };
System = { System = {
Archiver = cfg.archiverCmd; Archiver = cfgPreferences.archiveManager.command;
FallbackIconThemeName = "oxygen"; FallbackIconThemeName = "oxygen";
OnlyUserTemplates = false; OnlyUserTemplates = false;
SIUnit = false; SIUnit = false;
SuCommand = "${pkgs.lxqt.lxqt-sudo}/bin/lxqt-sudo %s"; SuCommand = "${pkgs.lxqt.lxqt-sudo}/bin/lxqt-sudo %s";
TemplateRunApp = false; TemplateRunApp = false;
TemplateTypeOnce = false; TemplateTypeOnce = false;
Terminal = cfg.terminalCmd; Terminal = cfgPreferences.terminalEmulator.command;
}; };
Thumbnail = { Thumbnail = {

View file

@ -1,4 +1,6 @@
{ config, ... }: { { config, osConfig, ... }: let
cfgPreferences = osConfig.myOptions.home-manager.preferences;
in {
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
settings = { settings = {
"$MOUSE_LMB" = "mouse:272"; "$MOUSE_LMB" = "mouse:272";
@ -26,14 +28,16 @@
# #
# Programs # Programs
# #
"SUPER, Return, exec, kitty" "SUPER, Return, exec, ${cfgPreferences.terminalEmulator.command}"
"SUPER, R, exec, walker" "SUPER, R, exec, ${cfgPreferences.launcher.command}"
# TODO: requires programs "SUPER, B, exec, ${cfgPreferences.browser.command}"
"SUPER, X, exec, ${cfgPreferences.fileManager.command}"
# TODO: Add qalculate
# #
# DE/WM Control programs # DE/WM Control programs
# #
# TODO: Requires programs # TODO: Add menuquit
"SUPER_SHIFT, L, exec, wlogout -p layer-shell" "SUPER_SHIFT, L, exec, wlogout -p layer-shell"
"SUPER_CTRL, L, exec, loginctl lock-session" "SUPER_CTRL, L, exec, loginctl lock-session"
"SUPER_SHIFT, T, exec, toggle-idle" "SUPER_SHIFT, T, exec, toggle-idle"

View file

@ -3,201 +3,195 @@
osConfig, osConfig,
... ...
}: let }: let
cfg = osConfig.myOptions.home-manager.programs; cfgPreferences = osConfig.myOptions.home-manager.preferences;
in { in {
xdg.mimeApps = let xdg.mimeApps = let
# TODO: Make options for these browser = cfgPreferences.browser.desktop;
browser = "firefox.desktop"; textEditor = cfgPreferences.textEditor.desktop;
textEditor = browser; # nvim doesn't work properly with xdg-open, just use the browser emailClient = cfgPreferences.emailClient.desktop;
emailClient = browser; documentViewer = cfgPreferences.documentViewer.desktop;
documentViewer = browser; # TODO: consider zathura (org.pwmt.zathura.desktop.desktop) fileManager = cfgPreferences.fileManager.desktop;
fileManager = "pcmanfm-qt.desktop"; archiveManager = cfgPreferences.archiveManager.desktop;
archiveManager = "org.kde.ark.desktop"; imageViewer = cfgPreferences.imageViewer.desktop;
imageViewer = mediaPlayer = cfgPreferences.mediaPlayer.desktop;
if cfg.applications.qimgv.enable
then "qimgv.desktop"
else if cfg.applications.nomacs.enable
then "org.nomacs.ImageLounge.desktop"
else browser;
mediaPlayer = "mpv.desktop";
associations = { associations = {
# Browser # Browser
"text/html" = [browser]; "text/html" = [browser];
"x-scheme-handler/http" = [browser]; "x-scheme-handler/http" = [browser];
"x-scheme-handler/https" = [browser]; "x-scheme-handler/https" = [browser];
"x-scheme-handler/about" = [browser]; "x-scheme-handler/about" = [browser];
"x-scheme-handler/unknown" = [browser]; "x-scheme-handler/unknown" = [browser];
"application/x-extension-htm" = [browser]; "application/x-extension-htm" = [browser];
"application/x-extension-html" = [browser]; "application/x-extension-html" = [browser];
"application/x-extension-shtml" = [browser]; "application/x-extension-shtml" = [browser];
"application/x-extension-xhtml" = [browser]; "application/x-extension-xhtml" = [browser];
"application/x-extension-xht" = [browser]; "application/x-extension-xht" = [browser];
"application/xhtml+xml" = [browser]; "application/xhtml+xml" = [browser];
"application/xhtml_xml" = [browser]; "application/xhtml_xml" = [browser];
# Image viewer # Image viewer
"image/*" = [imageViewer]; # wildcard associations don't work everywhere "image/*" = [imageViewer]; # wildcard associations don't work everywhere
"image/bmp" = [imageViewer]; "image/bmp" = [imageViewer];
"image/gif" = [imageViewer]; "image/gif" = [imageViewer];
"image/jpeg" = [imageViewer]; "image/jpeg" = [imageViewer];
"image/jpg" = [imageViewer]; "image/jpg" = [imageViewer];
"image/png" = [imageViewer]; "image/png" = [imageViewer];
"image/tiff" = [imageViewer]; "image/tiff" = [imageViewer];
"image/x-bmp" = [imageViewer]; "image/x-bmp" = [imageViewer];
"image/x-pcx" = [imageViewer]; "image/x-pcx" = [imageViewer];
"image/x-tga" = [imageViewer]; "image/x-tga" = [imageViewer];
"image/x-portable-pixmap" = [imageViewer]; "image/x-portable-pixmap" = [imageViewer];
"image/x-portable-bitmap" = [imageViewer]; "image/x-portable-bitmap" = [imageViewer];
"image/x-portable-greymap" = [imageViewer]; "image/x-portable-greymap" = [imageViewer];
"image/x-targa" = [imageViewer]; "image/x-targa" = [imageViewer];
"image/svg+xml" = [imageViewer]; "image/svg+xml" = [imageViewer];
"image/svg_xml" = [imageViewer]; "image/svg_xml" = [imageViewer];
# Media Player (video + audio) # Media Player (video + audio)
"video/*" = [mediaPlayer]; # wildcard associations don't work everywhere "video/*" = [mediaPlayer]; # wildcard associations don't work everywhere
"audio/*" = [mediaPlayer]; # -||- "audio/*" = [mediaPlayer]; # -||-
"video/mpeg" = [mediaPlayer]; "video/mpeg" = [mediaPlayer];
"video/x-mpeg2" = [mediaPlayer]; "video/x-mpeg2" = [mediaPlayer];
"video/x-mpeg3" = [mediaPlayer]; "video/x-mpeg3" = [mediaPlayer];
"video/mp4v-es" = [mediaPlayer]; "video/mp4v-es" = [mediaPlayer];
"video/x-m4v" = [mediaPlayer]; "video/x-m4v" = [mediaPlayer];
"video/mp4" = [mediaPlayer]; "video/mp4" = [mediaPlayer];
"video/divx" = [mediaPlayer]; "video/divx" = [mediaPlayer];
"video/vnd.divx" = [mediaPlayer]; "video/vnd.divx" = [mediaPlayer];
"video/msvideo" = [mediaPlayer]; "video/msvideo" = [mediaPlayer];
"video/x-msvideo" = [mediaPlayer]; "video/x-msvideo" = [mediaPlayer];
"video/ogg" = [mediaPlayer]; "video/ogg" = [mediaPlayer];
"video/quicktime" = [mediaPlayer]; "video/quicktime" = [mediaPlayer];
"video/vnd.rn-realvideo" = [mediaPlayer]; "video/vnd.rn-realvideo" = [mediaPlayer];
"video/x-avi" = [mediaPlayer]; "video/x-avi" = [mediaPlayer];
"video/avi" = [mediaPlayer]; "video/avi" = [mediaPlayer];
"video/x-flic" = [mediaPlayer]; "video/x-flic" = [mediaPlayer];
"video/fli" = [mediaPlayer]; "video/fli" = [mediaPlayer];
"video/x-flc" = [mediaPlayer]; "video/x-flc" = [mediaPlayer];
"video/flv" = [mediaPlayer]; "video/flv" = [mediaPlayer];
"video/x-flv" = [mediaPlayer]; "video/x-flv" = [mediaPlayer];
"video/x-theora" = [mediaPlayer]; "video/x-theora" = [mediaPlayer];
"video/x-theora+ogg" = [mediaPlayer]; "video/x-theora+ogg" = [mediaPlayer];
"video/x-matroska" = [mediaPlayer]; "video/x-matroska" = [mediaPlayer];
"video/mkv" = [mediaPlayer]; "video/mkv" = [mediaPlayer];
"video/webm" = [mediaPlayer]; "video/webm" = [mediaPlayer];
"video/x-ogm" = [mediaPlayer]; "video/x-ogm" = [mediaPlayer];
"video/x-ogm+ogg" = [mediaPlayer]; "video/x-ogm+ogg" = [mediaPlayer];
"video/dv" = [mediaPlayer]; "video/dv" = [mediaPlayer];
"video/mp2t" = [mediaPlayer]; "video/mp2t" = [mediaPlayer];
"video/vnd.mpegurl" = [mediaPlayer]; "video/vnd.mpegurl" = [mediaPlayer];
"video/3gp" = [mediaPlayer]; "video/3gp" = [mediaPlayer];
"video/3gpp" = [mediaPlayer]; "video/3gpp" = [mediaPlayer];
"video/3gpp2" = [mediaPlayer]; "video/3gpp2" = [mediaPlayer];
"application/x-cue" = [mediaPlayer]; "application/x-cue" = [mediaPlayer];
"application/vnd.ms-asf" = [mediaPlayer]; "application/vnd.ms-asf" = [mediaPlayer];
"application/x-matroska" = [mediaPlayer]; "application/x-matroska" = [mediaPlayer];
"application/x-ogm" = [mediaPlayer]; "application/x-ogm" = [mediaPlayer];
"application/x-ogm-audio" = [mediaPlayer]; "application/x-ogm-audio" = [mediaPlayer];
"application/x-ogm-video" = [mediaPlayer]; "application/x-ogm-video" = [mediaPlayer];
"application/x-shorten" = [mediaPlayer]; "application/x-shorten" = [mediaPlayer];
"application/x-mpegurl" = [mediaPlayer]; "application/x-mpegurl" = [mediaPlayer];
"application/vnd.apple.mpegurl" = [mediaPlayer]; "application/vnd.apple.mpegurl" = [mediaPlayer];
"application/ogg" = [mediaPlayer]; "application/ogg" = [mediaPlayer];
"application/x-ogg" = [mediaPlayer]; "application/x-ogg" = [mediaPlayer];
"application/mxf" = [mediaPlayer]; "application/mxf" = [mediaPlayer];
"application/sdp" = [mediaPlayer]; "application/sdp" = [mediaPlayer];
"application/smil" = [mediaPlayer]; "application/smil" = [mediaPlayer];
"application/x-smil" = [mediaPlayer]; "application/x-smil" = [mediaPlayer];
"application/streamingmedia" = [mediaPlayer]; "application/streamingmedia" = [mediaPlayer];
"application/x-streamingmedia" = [mediaPlayer]; "application/x-streamingmedia" = [mediaPlayer];
"application/vnd.rn-realmedia" = [mediaPlayer]; "application/vnd.rn-realmedia" = [mediaPlayer];
"application/vnd.rn-realmedia-vbr" = [mediaPlayer]; "application/vnd.rn-realmedia-vbr" = [mediaPlayer];
"application/x-extension-m4a" = [mediaPlayer]; "application/x-extension-m4a" = [mediaPlayer];
"audio/x-matroska" = [mediaPlayer]; "audio/x-matroska" = [mediaPlayer];
"audio/webm" = [mediaPlayer]; "audio/webm" = [mediaPlayer];
"audio/vorbis" = [mediaPlayer]; "audio/vorbis" = [mediaPlayer];
"audio/x-vorbis" = [mediaPlayer]; "audio/x-vorbis" = [mediaPlayer];
"audio/x-vorbis+ogg" = [mediaPlayer]; "audio/x-vorbis+ogg" = [mediaPlayer];
"audio/x-shorten" = [mediaPlayer]; "audio/x-shorten" = [mediaPlayer];
"audio/x-ape" = [mediaPlayer]; "audio/x-ape" = [mediaPlayer];
"audio/x-wavpack" = [mediaPlayer]; "audio/x-wavpack" = [mediaPlayer];
"audio/x-tta" = [mediaPlayer]; "audio/x-tta" = [mediaPlayer];
"audio/AMR" = [mediaPlayer]; "audio/AMR" = [mediaPlayer];
"audio/ac3" = [mediaPlayer]; "audio/ac3" = [mediaPlayer];
"audio/eac3" = [mediaPlayer]; "audio/eac3" = [mediaPlayer];
"audio/amr-wb" = [mediaPlayer]; "audio/amr-wb" = [mediaPlayer];
"audio/flac" = [mediaPlayer]; "audio/flac" = [mediaPlayer];
"audio/mp4" = [mediaPlayer]; "audio/mp4" = [mediaPlayer];
"audio/x-pn-au" = [mediaPlayer]; "audio/x-pn-au" = [mediaPlayer];
"audio/3gpp" = [mediaPlayer]; "audio/3gpp" = [mediaPlayer];
"audio/3gpp2" = [mediaPlayer]; "audio/3gpp2" = [mediaPlayer];
"audio/dv" = [mediaPlayer]; "audio/dv" = [mediaPlayer];
"audio/opus" = [mediaPlayer]; "audio/opus" = [mediaPlayer];
"audio/x-ms-asf" = [mediaPlayer]; "audio/x-ms-asf" = [mediaPlayer];
"audio/vnd.dts" = [mediaPlayer]; "audio/vnd.dts" = [mediaPlayer];
"audio/vnd.dts.hd" = [mediaPlayer]; "audio/vnd.dts.hd" = [mediaPlayer];
"audio/x-adpcm" = [mediaPlayer]; "audio/x-adpcm" = [mediaPlayer];
"audio/m3u" = [mediaPlayer]; "audio/m3u" = [mediaPlayer];
"audio/aac" = [mediaPlayer]; "audio/aac" = [mediaPlayer];
"audio/x-aac" = [mediaPlayer]; "audio/x-aac" = [mediaPlayer];
"audio/vnd.dolby.heaac.1" = [mediaPlayer]; "audio/vnd.dolby.heaac.1" = [mediaPlayer];
"audio/vnd.dolby.heaac.2" = [mediaPlayer]; "audio/vnd.dolby.heaac.2" = [mediaPlayer];
"audio/aiff" = [mediaPlayer]; "audio/aiff" = [mediaPlayer];
"audio/x-aiff" = [mediaPlayer]; "audio/x-aiff" = [mediaPlayer];
"audio/m4a" = [mediaPlayer]; "audio/m4a" = [mediaPlayer];
"audio/x-m4a" = [mediaPlayer]; "audio/x-m4a" = [mediaPlayer];
"audio/mp1" = [mediaPlayer]; "audio/mp1" = [mediaPlayer];
"audio/x-mp1" = [mediaPlayer]; "audio/x-mp1" = [mediaPlayer];
"audio/mp2" = [mediaPlayer]; "audio/mp2" = [mediaPlayer];
"audio/x-mp2" = [mediaPlayer]; "audio/x-mp2" = [mediaPlayer];
"audio/mp3" = [mediaPlayer]; "audio/mp3" = [mediaPlayer];
"audio/x-mp3" = [mediaPlayer]; "audio/x-mp3" = [mediaPlayer];
"audio/mpeg" = [mediaPlayer]; "audio/mpeg" = [mediaPlayer];
"audio/mpeg2" = [mediaPlayer]; "audio/mpeg2" = [mediaPlayer];
"audio/mpeg3" = [mediaPlayer]; "audio/mpeg3" = [mediaPlayer];
"audio/mpegurl" = [mediaPlayer]; "audio/mpegurl" = [mediaPlayer];
"audio/x-mpegurl" = [mediaPlayer]; "audio/x-mpegurl" = [mediaPlayer];
"audio/mpg" = [mediaPlayer]; "audio/mpg" = [mediaPlayer];
"audio/x-mpg" = [mediaPlayer]; "audio/x-mpg" = [mediaPlayer];
"audio/rn-mpeg" = [mediaPlayer]; "audio/rn-mpeg" = [mediaPlayer];
"audio/musepack" = [mediaPlayer]; "audio/musepack" = [mediaPlayer];
"audio/x-musepack" = [mediaPlayer]; "audio/x-musepack" = [mediaPlayer];
"audio/ogg" = [mediaPlayer]; "audio/ogg" = [mediaPlayer];
"audio/scpls" = [mediaPlayer]; "audio/scpls" = [mediaPlayer];
"audio/x-scpls" = [mediaPlayer]; "audio/x-scpls" = [mediaPlayer];
"audio/vnd.rn-realaudio" = [mediaPlayer]; "audio/vnd.rn-realaudio" = [mediaPlayer];
"audio/wav" = [mediaPlayer]; "audio/wav" = [mediaPlayer];
"audio/x-pn-wav" = [mediaPlayer]; "audio/x-pn-wav" = [mediaPlayer];
"audio/x-pn-windows-pcm" = [mediaPlayer]; "audio/x-pn-windows-pcm" = [mediaPlayer];
"audio/x-realaudio" = [mediaPlayer]; "audio/x-realaudio" = [mediaPlayer];
"audio/x-pn-realaudio" = [mediaPlayer]; "audio/x-pn-realaudio" = [mediaPlayer];
"audio/x-ms-wma" = [mediaPlayer]; "audio/x-ms-wma" = [mediaPlayer];
"audio/x-pls" = [mediaPlayer]; "audio/x-pls" = [mediaPlayer];
"audio/x-wav" = [mediaPlayer]; "audio/x-wav" = [mediaPlayer];
# Document Viewer # Document Viewer
"application/pdf" = [documentViewer]; "application/pdf" = [documentViewer];
"application/epub" = [documentViewer]; "application/epub" = [documentViewer];
"application/djvu" = [documentViewer]; "application/djvu" = [documentViewer];
"application/mobi" = [documentViewer]; "application/mobi" = [documentViewer];
# File & archive manager(s) # File & archive manager(s)
"inode/directory" = [fileManager]; "inode/directory" = [fileManager];
"application/zip" = [archiveManager]; "application/zip" = [archiveManager];
"application/x-xz-compressed-tar" = [archiveManager]; "application/x-xz-compressed-tar" = [archiveManager];
# Plain-text # Plain-text
"text/plain" = [textEditor]; "text/plain" = [textEditor];
"application/json" = [textEditor]; "application/json" = [textEditor];
# Application specific schemes # Application specific schemes
"x-scheme-handler/spotify" = ["spotify.desktop"]; "x-scheme-handler/spotify" = ["spotify.desktop"];
"x-scheme-handler/tg" = ["telegramdesktop.desktop"]; "x-scheme-handler/tg" = ["telegramdesktop.desktop"];
"x-scheme-handler/discord" = ["vesktop.desktop"]; "x-scheme-handler/discord" = ["vesktop.desktop"];
"x-scheme-handler/msteams" = ["teams.desktop"]; # I need it for school, don't judge me "x-scheme-handler/msteams" = ["teams.desktop"]; # I need it for school, don't judge me
# Misc # Misc
"x-scheme-handler/mailto" = [emailClient]; "x-scheme-handler/mailto" = [emailClient];
}; };
in { in {
enable = true; enable = true;
associations.added = associations; associations.added = associations;
@ -205,8 +199,8 @@ in {
}; };
home.sessionVariables = { home.sessionVariables = {
BROWSER = "firefox"; BROWSER = cfgPreferences.browser.command;
DEFAULT_BROWSER = "firefox"; DEFAULT_BROWSER = cfgPreferences.browser.command;
TERMINAL = "kitty"; TERMINAL = cfgPreferences.terminalEmulator.command;
}; };
} }

View file

@ -8,6 +8,7 @@ in
./wms.nix ./wms.nix
./theme.nix ./theme.nix
./services.nix ./services.nix
./preferences.nix
]; ];
options.myOptions.home-manager = { options.myOptions.home-manager = {

View file

@ -0,0 +1,34 @@
{ lib, ... }: let
inherit (lib) mkOption types;
mkPreferenceCmdOption = name: commandDefault: mkOption {
type = types.str;
description = "The command to start your preferred ${name}.";
default = commandDefault;
};
mkPreferenceDesktopOption = name: desktopDefault: mkOption {
type = types.str;
description = "The desktop (application) file for your preferred ${name}.";
default = desktopDefault;
};
mkPreferenceOptions = name: commandDefault: desktopDefault: {
command = mkPreferenceCmdOption name commandDefault;
desktop = mkPreferenceDesktopOption name desktopDefault;
};
in
{
options.myOptions.home-manager.preferences = {
browser = mkPreferenceOptions "browser" "firefox" "firefox.desktop";
terminalEmulator = mkPreferenceOptions "terminal emulator" "kitty" "kitty.desktop";
textEditor = mkPreferenceOptions "editor" "nvim" "nvim.desktop";
fileManager = mkPreferenceOptions "file manager" "pcmanfm-qt" "pcmanfm-qt.desktop";
imageViewer = mkPreferenceOptions "image viewer" "qimgv" "qimgv.desktop";
mediaPlayer = mkPreferenceOptions "media player" "mpv" "mpv.desktop";
archiveManager = mkPreferenceOptions "archive manager" "ark" "org.kde.ark.desktop";
documentViewer = mkPreferenceOptions "document viewer" "firefox" "firefox.desktop"; # TODO: consider zathura (org.pwmt.zathura.desktop.desktop)
emailClient = mkPreferenceOptions "email client" "firefox" "firefox.desktop";
launcher.command = mkPreferenceCmdOption "launcher" "walker";
};
}

View file

@ -49,25 +49,7 @@ in
}; };
file-managers = { file-managers = {
pcmanfm-qt = { pcmanfm-qt.enable = mkEnableOption "Pcmanfm-qt (extremely fast and lightweight file manager and the standard file manager of LXDE)";
enable = mkEnableOption "Pcmanfm-qt (extremely fast and lightweight file manager and the standard file manager of LXDE)";
terminalCmd = mkOption {
type = types.str;
default = "kitty";
description = ''
Command used to open the terminal emulator.
'';
};
archiverCmd = mkOption {
type = types.str;
default = "ark";
description = ''
Command used to open the archiver (zip/tar explorer).
'';
};
};
}; };
tools = { tools = {