From f5bcebf6e7bb79ed5c5b0783c8b82cbcd2707a29 Mon Sep 17 00:00:00 2001 From: Bryan Ramos Date: Tue, 10 Dec 2024 21:31:16 -0500 Subject: [PATCH] wm changes --- src/user/modules/gui/wm/hyprland/default.nix | 14 +-- .../gui/wm/shared/mimeapps/default.nix | 32 ++++++ src/user/modules/gui/wm/sway/config/sway.nix | 100 ------------------ src/user/modules/gui/wm/sway/default.nix | 98 ++++++++++++++++- 4 files changed, 137 insertions(+), 107 deletions(-) create mode 100644 src/user/modules/gui/wm/shared/mimeapps/default.nix delete mode 100644 src/user/modules/gui/wm/sway/config/sway.nix diff --git a/src/user/modules/gui/wm/hyprland/default.nix b/src/user/modules/gui/wm/hyprland/default.nix index 8f5833b..e404e55 100644 --- a/src/user/modules/gui/wm/hyprland/default.nix +++ b/src/user/modules/gui/wm/hyprland/default.nix @@ -204,12 +204,14 @@ in platformTheme.name = "gtk"; }; - xdg.portal = { - enable = true; - extraPortals = with pkgs; [ - xdg-desktop-portal-hyprland - ]; - config.common.default = "*"; + xdg = { + portal = { + enable = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-hyprland + ]; + config.common.default = "*"; + }; }; programs = { diff --git a/src/user/modules/gui/wm/shared/mimeapps/default.nix b/src/user/modules/gui/wm/shared/mimeapps/default.nix new file mode 100644 index 0000000..7f94be9 --- /dev/null +++ b/src/user/modules/gui/wm/shared/mimeapps/default.nix @@ -0,0 +1,32 @@ +{ pkgs, lib, config, ... }: + +let + browser = config.programs; + + fileTypes = [ + "text/html" "application/pdf" "application/xml" + "image/png" "image/svg+xml" "image/jpg" + "image/jpeg" "image/gif" "image/webp" + "image/avif" "image/bmp" "image/tiff" + ]; + + defaultBrowser = if browser.firefox.enable then + "firefox.desktop" + else if browser.brave.enable then + "brave-browser.desktop" + else if browser.chromium.enable then + "chromium.desktop" + else null; + +in +{ + xdg.mimeApps = lib.optionalAttrs (defaultBrowser != null && config.xdg.portal.enable) { + enable = true; + defaultApplications = builtins.listToAttrs ( + map (type: { + name = type; + value = [ defaultBrowser ]; + }) fileTypes + ); + }; +} diff --git a/src/user/modules/gui/wm/sway/config/sway.nix b/src/user/modules/gui/wm/sway/config/sway.nix deleted file mode 100644 index 2c484da..0000000 --- a/src/user/modules/gui/wm/sway/config/sway.nix +++ /dev/null @@ -1,100 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - modifier = config.wayland.windowManager.sway.config.modifier; - - wallpaper = builtins.fetchurl { - url = "https://images6.alphacoders.com/117/1174033.png"; - sha256 = "1ph5m9s57076jx6042iipqx2ifzadmd5z4lf5l49wgq4jb92mp16"; - }; - -in -{ enable = true; - xwayland = true; - #wrapperFeatures.gtk = true; - - extraSessionCommands = '' - export _JAVA_AWT_WM_NONREPARENTING=1 - ''; - - config = { - fonts = { - names = [ "Terminus" ]; - }; - - output = { - HDMI-A-1 = { - resolution = "1920x1080"; - position = "0,0"; - bg = "${wallpaper} fill"; - }; - DP-1 = { - resolution = "1920x1080"; - position = "1920,0"; - bg = "${wallpaper} fill"; - }; - }; - modifier = "Mod1"; - menu = "rofi -show drun -show-icons -drun-icon-theme Qogir -font 'Noto Sans 14'"; - terminal = "${pkgs.alacritty}/bin/alacritty"; - - input = { - keyboard = { - xkb_numlock = "enabled"; - xkb_layout = "us"; - }; - pointer = { - accel_profile = "flat"; - pointer_accel = "0.65"; - }; - }; - - bars = [ - { - position = "top"; - statusCommand = ''while :; do echo "$(free -h | awk '/^Mem/ {print $3}') '|' $(date +'%I:%M:%S %p') '|' $(date +'%m-%d-%Y')"; sleep 1; done''; - fonts = { - names = [ "Terminus" ]; - size = 10.0; - }; - colors = { - background = "#0A0E14"; - statusline = "#FFFFFF"; - }; - } - ]; - - gaps = { - smartGaps = false; - inner = 10; - }; - - floating = { - titlebar = false; - border = 0; - criteria = [ - { - title = "Android Emulator"; - } - ]; - }; - - window = { - titlebar = false; - border= 0; - }; - - keybindings = lib.mkOptionDefault { - "${modifier}+q" = "kill"; - "Print" = "exec grim ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png"; - "Shift+Print" = "exec grim -g \"$(slurp)\" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png"; - "${modifier}+Print" = ''exec sh -c 'grim -g "$(swaymsg -t get_tree | jq -j '"'"'.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"'"'"')" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png' ''; - "${modifier}+Shift+f" = "exec alacritty -e sh -c 'EDITOR=nvim ranger'"; - "${modifier}+Shift+d" = "exec rofi -modi emoji -show emoji"; - }; - }; - - extraConfig = '' - exec_always ${pkgs.autotiling}/bin/autotiling - ''; -} diff --git a/src/user/modules/gui/wm/sway/default.nix b/src/user/modules/gui/wm/sway/default.nix index 041c047..6a3f5e5 100644 --- a/src/user/modules/gui/wm/sway/default.nix +++ b/src/user/modules/gui/wm/sway/default.nix @@ -3,11 +3,107 @@ with lib; let cfg = config.modules.user.gui.wm.sway; + modifier = config.wayland.windowManager.sway.config.modifier; + + wallpaper = builtins.fetchurl { + url = "https://images6.alphacoders.com/117/1174033.png"; + sha256 = "1ph5m9s57076jx6042iipqx2ifzadmd5z4lf5l49wgq4jb92mp16"; + }; in { options.modules.user.gui.wm.sway = { enable = mkEnableOption "user.gui.wm.sway"; }; config = mkIf cfg.enable { - wayland.windowManager.sway = import ./config/sway.nix { inherit pkgs config lib; }; + wayland.windowManager.sway = { + enable = true; + xwayland = true; + #wrapperFeatures.gtk = true; + + extraSessionCommands = '' + export _JAVA_AWT_WM_NONREPARENTING=1 + ''; + + config = { + fonts = { + names = [ "Terminus" ]; + }; + + output = { + HDMI-A-1 = { + resolution = "1920x1080"; + position = "0,0"; + bg = "${wallpaper} fill"; + }; + DP-1 = { + resolution = "1920x1080"; + position = "1920,0"; + bg = "${wallpaper} fill"; + }; + }; + modifier = "Mod1"; + menu = "rofi -show drun -show-icons -drun-icon-theme Qogir -font 'Noto Sans 14'"; + terminal = "${pkgs.alacritty}/bin/alacritty"; + + input = { + keyboard = { + xkb_numlock = "enabled"; + xkb_layout = "us"; + }; + pointer = { + accel_profile = "flat"; + pointer_accel = "0.65"; + }; + }; + + bars = [ + { + position = "top"; + statusCommand = ''while :; do echo "$(free -h | awk '/^Mem/ {print $3}') '|' $(date +'%I:%M:%S %p') '|' $(date +'%m-%d-%Y')"; sleep 1; done''; + fonts = { + names = [ "Terminus" ]; + size = 10.0; + }; + colors = { + background = "#0A0E14"; + statusline = "#FFFFFF"; + }; + } + ]; + + gaps = { + smartGaps = false; + inner = 10; + }; + + floating = { + titlebar = false; + border = 0; + criteria = [ + { + title = "Android Emulator"; + } + ]; + }; + + window = { + titlebar = false; + border= 0; + }; + + keybindings = lib.mkOptionDefault { + "${modifier}+q" = "kill"; + "Print" = "exec grim ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png"; + "Shift+Print" = "exec grim -g \"$(slurp)\" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png"; + "${modifier}+Print" = ''exec sh -c 'grim -g "$(swaymsg -t get_tree | jq -j '"'"'.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"'"'"')" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png' ''; + "${modifier}+Shift+f" = "exec alacritty -e sh -c 'EDITOR=nvim ranger'"; + "${modifier}+Shift+d" = "exec rofi -modi emoji -show emoji"; + }; + }; + + extraConfig = '' + exec_always ${pkgs.autotiling}/bin/autotiling + ''; + }; + programs.rofi = import ./config/rofi { inherit pkgs config lib; }; home.file.".config/rofi" = {