From 50f3f4f27e6f81cabf93439541024fc3518ae15b Mon Sep 17 00:00:00 2001 From: sxmourai Date: Wed, 17 May 2023 17:23:42 +0200 Subject: [PATCH 01/17] Renamed hyperland to hyprland, fixed seatd via post_installation and installed waybar --- .../desktops/{hyperland.py => hyprland.py} | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) rename archinstall/default_profiles/desktops/{hyperland.py => hyprland.py} (65%) diff --git a/archinstall/default_profiles/desktops/hyperland.py b/archinstall/default_profiles/desktops/hyprland.py similarity index 65% rename from archinstall/default_profiles/desktops/hyperland.py rename to archinstall/default_profiles/desktops/hyprland.py index e55dd7c4f7..2fb2c04d58 100644 --- a/archinstall/default_profiles/desktops/hyperland.py +++ b/archinstall/default_profiles/desktops/hyprland.py @@ -2,14 +2,16 @@ from archinstall.default_profiles.profile import ProfileType, GreeterType from archinstall.default_profiles.xorg import XorgProfile +from archinstall.lib.menu.menu import Menu if TYPE_CHECKING: + from archinstall.lib.installer import Installer _: Any -class HyperlandProfile(XorgProfile): +class HyprlandProfile(XorgProfile): def __init__(self): - super().__init__('Hyperland', ProfileType.DesktopEnv, description='') + super().__init__('Hyprland', ProfileType.DesktopEnv, description='') @property def packages(self) -> List[str]: @@ -20,8 +22,13 @@ def packages(self) -> List[str]: "kitty", "qt5-wayland", "qt6-wayland" + "waybar-hyprland", ] + def post_install(self, install_session: 'Installer'): + # Fix seatd + install_session.arch_chroot("systemctl enable --now seatd") + @property def default_greeter_type(self) -> Optional[GreeterType]: return GreeterType.Sddm From 7bbcf6ad8b3f52d7f549b491971146ba6c62dfad Mon Sep 17 00:00:00 2001 From: sxmourai Date: Wed, 17 May 2023 17:33:00 +0200 Subject: [PATCH 02/17] Removed the launching of seatd on the installation process --- archinstall/default_profiles/desktops/hyprland.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/default_profiles/desktops/hyprland.py b/archinstall/default_profiles/desktops/hyprland.py index 2fb2c04d58..098ca7c7a7 100644 --- a/archinstall/default_profiles/desktops/hyprland.py +++ b/archinstall/default_profiles/desktops/hyprland.py @@ -27,7 +27,7 @@ def packages(self) -> List[str]: def post_install(self, install_session: 'Installer'): # Fix seatd - install_session.arch_chroot("systemctl enable --now seatd") + install_session.arch_chroot("systemctl enable seatd") @property def default_greeter_type(self) -> Optional[GreeterType]: From 13fd1b8762f4b072082a7feb3e372e8e1b2df6c0 Mon Sep 17 00:00:00 2001 From: sxmourai Date: Wed, 17 May 2023 19:21:02 +0200 Subject: [PATCH 03/17] Starting to add nvidia support, and automatic configuring of hyprland --- .../default_profiles/desktops/hyprland.py | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/archinstall/default_profiles/desktops/hyprland.py b/archinstall/default_profiles/desktops/hyprland.py index 098ca7c7a7..af8c7be5a7 100644 --- a/archinstall/default_profiles/desktops/hyprland.py +++ b/archinstall/default_profiles/desktops/hyprland.py @@ -1,6 +1,6 @@ from typing import List, Optional, Any, TYPE_CHECKING -from archinstall.default_profiles.profile import ProfileType, GreeterType +from archinstall.default_profiles.profile import ProfileType, GreeterType, SelectResult from archinstall.default_profiles.xorg import XorgProfile from archinstall.lib.menu.menu import Menu @@ -11,7 +11,7 @@ class HyprlandProfile(XorgProfile): def __init__(self): - super().__init__('Hyprland', ProfileType.DesktopEnv, description='') + super().__init__('Hyprland', ProfileType.WindowMgr, description='') @property def packages(self) -> List[str]: @@ -23,11 +23,53 @@ def packages(self) -> List[str]: "qt5-wayland", "qt6-wayland" "waybar-hyprland", + "grim", + "slurp", + "hyprpaper", ] + def post_install(self, install_session: 'Installer'): - # Fix seatd - install_session.arch_chroot("systemctl enable seatd") + # Fix seatd + install_session.arch_chroot("systemctl enable seatd") + # For nvidia: + # install_session.arch_chroot("pacman -Sy nvidia-dkms") + # if install_session.bootloader == "systemd-boot": + # install_session.arch_chroot("echo nvidia_drm.modeset=1 >> /boot/loader/entries/arch.conf") + # elif install_session.bootloader == "GRUB": + # with open(f"{install_session.target}/etc/default/grub", "r") as f: + # c = f.readlines() + # for i,line in enumerate(c): + # if line.startswith("GRUB_CMDLINE_LINUX_DEFAULT="): + # c[i] = f"{c[i:-1]} nvidia_drm.modeset=1\"" + # with open(f"{install_session.target}/etc/default/grub", "w") as f: + # f.write(c) + # install_session.arch_chroot("grub-mkconfig -o /boot/grub/grub.cfg") + # install_session.modules += ["nvidia", "nvidia_modeset", "nvidia_uvm", "nvidia_drm"] + # install_session.arch_chroot("echo options nvidia-drm modeset=1 >> /etc/modprobe.d/nvidia.conf") + # if self.multi-monitor: # Check with lshw -c display + # install_session.arch_chroot("pacman -R optimus-manager") + # warn_user("You need to change your BIOS settings from hybrid graphics to discrete graphics") + # for user in self.selected_users: + # with open(f"{install_session.target}/home/{user}/.config/hypr/hyprland.conf", "a") as f: + # f.writelines([ + # "env = LIBVA_DRIVER_NAME,nvidia", + # "env = XDG_SESSION_TYPE,wayland", + # "env = GBM_BACKEND,nvidia-drm", + # "env = __GLX_VENDOR_LIBRARY_NAME,nvidia", + # "env = WLR_NO_HARDWARE_CURSORS,1" + # ]) + + # def do_on_select(self): + # title = str(_("Configure Hyprland")) + # options = [] + # options += str(_(f"Select users ({' '.join(self.selected_users)})")) + # #TODO: Configure seat access (seatd / polkit) + # chosen = Menu(title, options, skip=False).run() + # if chosen.value.startswith("Select users"): + # user_selected = Menu("Select User(s)", created_users, multi=True).run() + # self.selected_users = user_selected.multi_value + @property def default_greeter_type(self) -> Optional[GreeterType]: From 22558d84ce8382543d65ba1074cb96edf92d3f1e Mon Sep 17 00:00:00 2001 From: sxmourai Date: Thu, 18 May 2023 11:00:48 +0200 Subject: [PATCH 04/17] Starting to add auto configuration of hyprland... But this will need maintenance --- .../default_profiles/desktops/hyprland.py | 158 +++++++++++++++++- 1 file changed, 149 insertions(+), 9 deletions(-) diff --git a/archinstall/default_profiles/desktops/hyprland.py b/archinstall/default_profiles/desktops/hyprland.py index af8c7be5a7..8f84af2319 100644 --- a/archinstall/default_profiles/desktops/hyprland.py +++ b/archinstall/default_profiles/desktops/hyprland.py @@ -1,3 +1,4 @@ +from enum import Enum from typing import List, Optional, Any, TYPE_CHECKING from archinstall.default_profiles.profile import ProfileType, GreeterType, SelectResult @@ -8,10 +9,16 @@ from archinstall.lib.installer import Installer _: Any +class FileManager(Enum): + dolphin = 'dolphin' + thunar = 'thunar' + class HyprlandProfile(XorgProfile): def __init__(self): super().__init__('Hyprland', ProfileType.WindowMgr, description='') + self.selected_users = [] + self.file_manager = FileManager.dolphin @property def packages(self) -> List[str]: @@ -32,6 +39,132 @@ def packages(self) -> List[str]: def post_install(self, install_session: 'Installer'): # Fix seatd install_session.arch_chroot("systemctl enable seatd") + for user in self.selected_users: + chrooted_conf = f"/home/{user}/.config" + install_session.arch_chroot(f"mkdir {chrooted_conf}/hypr -p") + uconf = f"{install_session.target}{chrooted_conf}" + with open(f"{uconf}/hypr/hyprland.conf", "w") as f: + f.write( +"""# THIS IS PRECONFIGURED BY ARCHINSTALL +# The wiki for hyprland is here : https://wiki.hyprland.org/Getting-Started/Master-Tutorial +# If you encounter any problems, bugs or crashes, go and follow the tutorial""") + f.write("monitor=,preferred,auto,auto") + f.write("exec-once = waybar & hyprpaper & kitty # Autostarting kitty if you have problems with keyboard shortcuts etc.") + f.write("env = XCURSOR_SIZE,24") + f.write("input {\n kb_layout = {}".format(keyboard_layout)) + f.write( +""" kb_variant = + kb_model = + kb_options = + kb_rules = + follow_mouse = 1 + touchpad { natural_scroll = false } + sensitivity = 0 # -1.0 - 1.0, 0 means no modification. +""") + f.write(""" +general { + # See https://wiki.hyprland.org/Configuring/Variables/ for more + gaps_in = 5 + gaps_out = 20 + border_size = 2 + col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg + col.inactive_border = rgba(595959aa) + + layout = dwindle +}""") + f.write(""" +decoration { + # See https://wiki.hyprland.org/Configuring/Variables/ for more + rounding = 10 + blur = true + blur_size = 3 + blur_passes = 1 + blur_new_optimizations = true + + drop_shadow = true + shadow_range = 4 + shadow_render_power = 3 + col.shadow = rgba(1a1a1aee) +}""") + f.write(""" +animations { + enabled = true + # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more + bezier = myBezier, 0.05, 0.9, 0.1, 1.05 + + animation = windows, 1, 7, myBezier + animation = windowsOut, 1, 7, default, popin 80% + animation = border, 1, 10, default + animation = borderangle, 1, 8, default + animation = fade, 1, 7, default + animation = workspaces, 1, 6, default +}""") + f.write(""" +dwindle { + # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more + pseudotile = true # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below + preserve_split = true # you probably want this +} + +master { + # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more + new_is_master = true +} + +gestures { + # See https://wiki.hyprland.org/Configuring/Variables/ for more + workspace_swipe = false +}""") + f.write(""" +$mainMod = SUPER + +bind = $mainMod, Q, exec, kitty +bind = $mainMod, C, killactive, +bind = $mainMod, M, exit, +bind = $mainMod, E, exec, {} +bind = $mainMod, V, togglefloating, +bind = $mainMod, R, exec, wofi --show drun +bind = $mainMod, P, pseudo, # dwindle +bind = $mainMod, J, togglesplit, # dwindle + +# Move focus with mainMod + arrow keys +bind = $mainMod, left, movefocus, l +bind = $mainMod, right, movefocus, r +bind = $mainMod, up, movefocus, u +bind = $mainMod, down, movefocus, d + +# Switch workspaces with mainMod + [0-9] +bind = $mainMod, 1, workspace, 1 +bind = $mainMod, 2, workspace, 2 +bind = $mainMod, 3, workspace, 3 +bind = $mainMod, 4, workspace, 4 +bind = $mainMod, 5, workspace, 5 +bind = $mainMod, 6, workspace, 6 +bind = $mainMod, 7, workspace, 7 +bind = $mainMod, 8, workspace, 8 +bind = $mainMod, 9, workspace, 9 +bind = $mainMod, 0, workspace, 10 + +# Move active window to a workspace with mainMod + SHIFT + [0-9] +bind = $mainMod SHIFT, 1, movetoworkspace, 1 +bind = $mainMod SHIFT, 2, movetoworkspace, 2 +bind = $mainMod SHIFT, 3, movetoworkspace, 3 +bind = $mainMod SHIFT, 4, movetoworkspace, 4 +bind = $mainMod SHIFT, 5, movetoworkspace, 5 +bind = $mainMod SHIFT, 6, movetoworkspace, 6 +bind = $mainMod SHIFT, 7, movetoworkspace, 7 +bind = $mainMod SHIFT, 8, movetoworkspace, 8 +bind = $mainMod SHIFT, 9, movetoworkspace, 9 +bind = $mainMod SHIFT, 0, movetoworkspace, 10 + +# Scroll through existing workspaces with mainMod + scroll +bind = $mainMod, mouse_down, workspace, e+1 +bind = $mainMod, mouse_up, workspace, e-1 + +# Move/resize windows with mainMod + LMB/RMB and dragging +bindm = $mainMod, mouse:272, movewindow +bindm = $mainMod, mouse:273, resizewindow +""".format(self.file_manager)) # For nvidia: # install_session.arch_chroot("pacman -Sy nvidia-dkms") # if install_session.bootloader == "systemd-boot": @@ -60,16 +193,23 @@ def post_install(self, install_session: 'Installer'): # "env = WLR_NO_HARDWARE_CURSORS,1" # ]) - # def do_on_select(self): - # title = str(_("Configure Hyprland")) - # options = [] - # options += str(_(f"Select users ({' '.join(self.selected_users)})")) - # #TODO: Configure seat access (seatd / polkit) - # chosen = Menu(title, options, skip=False).run() - # if chosen.value.startswith("Select users"): - # user_selected = Menu("Select User(s)", created_users, multi=True).run() - # self.selected_users = user_selected.multi_value + def do_on_select(self): + title = str(_("Configure Hyprland")) + options = [] + options += str(_(f"Select users ({' '.join(self.selected_users)})")) + options += str(_(f"File manager ({' '.join(self.file_managers)})")) + + #TODO: Configure seat access (seatd / polkit) + chosen = Menu(title, options, skip=False).run() + if chosen.value.startswith("Select users"): + already_created_users = [] + user_selected = Menu("Select User(s)", already_created_users, multi=True, preset_values=self.selected_users).run() + self.selected_users = user_selected.multi_value + elif chosen.value.startswith("File manager"): + self.file_manager = Menu("Select graphical file manager", [fm.value for fm in FileManager]).run().value + + @property def default_greeter_type(self) -> Optional[GreeterType]: From 1f9f9ce9c1ed7012242320bbea9d6a0d91d4abce Mon Sep 17 00:00:00 2001 From: sxmourai Date: Thu, 18 May 2023 11:12:37 +0200 Subject: [PATCH 05/17] Added hyprpaper auto config Gonna make waybar auto config next --- .../default_profiles/desktops/hyprland.py | 115 ++++++++++-------- 1 file changed, 65 insertions(+), 50 deletions(-) diff --git a/archinstall/default_profiles/desktops/hyprland.py b/archinstall/default_profiles/desktops/hyprland.py index 8f84af2319..c55589342b 100644 --- a/archinstall/default_profiles/desktops/hyprland.py +++ b/archinstall/default_profiles/desktops/hyprland.py @@ -13,55 +13,28 @@ class FileManager(Enum): dolphin = 'dolphin' thunar = 'thunar' +HYPRLAND_CONFIG = """# THIS IS PRECONFIGURED BY ARCHINSTALL +# The wiki for hyprland is here : https://wiki.hyprland.org/Getting-Started/Master-Tutorial +# If you encounter any problems, bugs or crashes, go and check the wiki +# Have fun ! -class HyprlandProfile(XorgProfile): - def __init__(self): - super().__init__('Hyprland', ProfileType.WindowMgr, description='') - self.selected_users = [] - self.file_manager = FileManager.dolphin +monitor=,preferred,auto,auto - @property - def packages(self) -> List[str]: - return [ - "hyprland", - "dunst", - "xdg-desktop-portal-hyprland", - "kitty", - "qt5-wayland", - "qt6-wayland" - "waybar-hyprland", - "grim", - "slurp", - "hyprpaper", - ] - +exec-once = waybar & hyprpaper & kitty # Autostarting kitty if you have problems with keyboard shortcuts etc.") - def post_install(self, install_session: 'Installer'): - # Fix seatd - install_session.arch_chroot("systemctl enable seatd") - for user in self.selected_users: - chrooted_conf = f"/home/{user}/.config" - install_session.arch_chroot(f"mkdir {chrooted_conf}/hypr -p") - uconf = f"{install_session.target}{chrooted_conf}" - with open(f"{uconf}/hypr/hyprland.conf", "w") as f: - f.write( -"""# THIS IS PRECONFIGURED BY ARCHINSTALL -# The wiki for hyprland is here : https://wiki.hyprland.org/Getting-Started/Master-Tutorial -# If you encounter any problems, bugs or crashes, go and follow the tutorial""") - f.write("monitor=,preferred,auto,auto") - f.write("exec-once = waybar & hyprpaper & kitty # Autostarting kitty if you have problems with keyboard shortcuts etc.") - f.write("env = XCURSOR_SIZE,24") - f.write("input {\n kb_layout = {}".format(keyboard_layout)) - f.write( -""" kb_variant = +env = XCURSOR_SIZE,24 + +input { + kb_layout = {kb} + kb_variant = kb_model = kb_options = kb_rules = follow_mouse = 1 touchpad { natural_scroll = false } sensitivity = 0 # -1.0 - 1.0, 0 means no modification. -""") - f.write(""" +} + general { # See https://wiki.hyprland.org/Configuring/Variables/ for more gaps_in = 5 @@ -71,8 +44,8 @@ def post_install(self, install_session: 'Installer'): col.inactive_border = rgba(595959aa) layout = dwindle -}""") - f.write(""" +} + decoration { # See https://wiki.hyprland.org/Configuring/Variables/ for more rounding = 10 @@ -85,8 +58,8 @@ def post_install(self, install_session: 'Installer'): shadow_range = 4 shadow_render_power = 3 col.shadow = rgba(1a1a1aee) -}""") - f.write(""" +} + animations { enabled = true # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more @@ -98,8 +71,8 @@ def post_install(self, install_session: 'Installer'): animation = borderangle, 1, 8, default animation = fade, 1, 7, default animation = workspaces, 1, 6, default -}""") - f.write(""" +} + dwindle { # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more pseudotile = true # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below @@ -114,14 +87,13 @@ def post_install(self, install_session: 'Installer'): gestures { # See https://wiki.hyprland.org/Configuring/Variables/ for more workspace_swipe = false -}""") - f.write(""" +} $mainMod = SUPER bind = $mainMod, Q, exec, kitty bind = $mainMod, C, killactive, bind = $mainMod, M, exit, -bind = $mainMod, E, exec, {} +bind = $mainMod, E, exec, {fm} bind = $mainMod, V, togglefloating, bind = $mainMod, R, exec, wofi --show drun bind = $mainMod, P, pseudo, # dwindle @@ -164,7 +136,50 @@ def post_install(self, install_session: 'Installer'): # Move/resize windows with mainMod + LMB/RMB and dragging bindm = $mainMod, mouse:272, movewindow bindm = $mainMod, mouse:273, resizewindow -""".format(self.file_manager)) +""" + +HYPRPAPER_CONFIG = """# PRECONFIGURED BY ARCHINSTALL +# Before changing wallpaper, check how stuff works : https://github.com/hyprwm/hyprpaper#Usage +preload = {path} +wallpaper = ,{path}""" + +def get_hypr_conf(keyboard_layout, file_manager): + return HYPRLAND_CONFIG.format(kb=keyboard_layout, fm=file_manager) +def get_wallpapaer_conf(wallpaper_path): + return HYPRPAPER_CONFIG.format(path=wallpaper_path) + +class HyprlandProfile(XorgProfile): + def __init__(self): + super().__init__('Hyprland', ProfileType.WindowMgr, description='') + self.selected_users = [] + self.file_manager = FileManager.dolphin + + @property + def packages(self) -> List[str]: + return [ + "hyprland", + "dunst", + "xdg-desktop-portal-hyprland", + "kitty", + "qt5-wayland", + "qt6-wayland" + "waybar-hyprland", + "grim", + "slurp", + "hyprpaper", + ] + + + def post_install(self, install_session: 'Installer'): + # Fix seatd + install_session.arch_chroot("systemctl enable seatd") + keyboard_layout = "us" #TODO: How to get selected keyboard layout for user ? + for user in self.selected_users: + chrooted_conf = f"/home/{user}/.config" + install_session.arch_chroot(f"mkdir {chrooted_conf}/hypr -p") + uconf = f"{install_session.target}{chrooted_conf}" + with open(f"{uconf}/hypr/hyprland.conf", "w") as f: + f.write(hyprland_config) # For nvidia: # install_session.arch_chroot("pacman -Sy nvidia-dkms") # if install_session.bootloader == "systemd-boot": From 16843844ca28f3261b4ae6307ba15ae4cd75d820 Mon Sep 17 00:00:00 2001 From: sxmourai Date: Thu, 18 May 2023 11:21:29 +0200 Subject: [PATCH 06/17] Waybar auto config is starting... I can't test rn I'm on vacation and my connection is quite bad (68 days for arch iso) --- .../default_profiles/desktops/hyprland.py | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/archinstall/default_profiles/desktops/hyprland.py b/archinstall/default_profiles/desktops/hyprland.py index c55589342b..fb9d24f808 100644 --- a/archinstall/default_profiles/desktops/hyprland.py +++ b/archinstall/default_profiles/desktops/hyprland.py @@ -143,10 +143,28 @@ class FileManager(Enum): preload = {path} wallpaper = ,{path}""" +WAYBAR_CONFIG = """""" +WAYBAR_CSS = """# PRECONFIGURED BY ARCHINSTALL +# Configure as you need, and check some examples on the internet +* { + font-size: 12px; + font-family: monospace; + font-weight: bold; +} + +window#waybar { + background: #292b2e; + color: #fdf6e3; +}""" + def get_hypr_conf(keyboard_layout, file_manager): return HYPRLAND_CONFIG.format(kb=keyboard_layout, fm=file_manager) -def get_wallpapaer_conf(wallpaper_path): +def get_wallpaper_conf(wallpaper_path): return HYPRPAPER_CONFIG.format(path=wallpaper_path) +def get_waybar_conf(): + return WAYBAR_CONFIG +def get_waybar_css(): + return WAYBAR_CSS class HyprlandProfile(XorgProfile): def __init__(self): @@ -176,10 +194,18 @@ def post_install(self, install_session: 'Installer'): keyboard_layout = "us" #TODO: How to get selected keyboard layout for user ? for user in self.selected_users: chrooted_conf = f"/home/{user}/.config" - install_session.arch_chroot(f"mkdir {chrooted_conf}/hypr -p") + install_session.arch_chroot(f"mkdir {chrooted_conf}/hypr/wallpapers -p") + install_session.arch_chroot(f"mkdir {chrooted_conf}/waybar") + install_session.arch_chroot(f"wget --output {chrooted_conf}/hypr/wallpapers/default_arch.jpg https://images.hdqwalls.com/wallpapers/arch-liinux-4k-t0.jpg") uconf = f"{install_session.target}{chrooted_conf}" with open(f"{uconf}/hypr/hyprland.conf", "w") as f: - f.write(hyprland_config) + f.write(get_hypr_conf(keyboard_layout, self.file_manager.value)) + with open(f"{uconf}/hypr/hyprpaper.conf", "w") as f: + f.write(get_wallpaper_conf(f"{uconf}/hypr/wallpapers/default_arch.jpg")) + with open(f"{uconf}/waybar/config", "w") as f: + f.write(get_waybar_conf()) + with open(f"{uconf}/waybar/style.css", "w") as f: + f.write(get_waybar_css()) # For nvidia: # install_session.arch_chroot("pacman -Sy nvidia-dkms") # if install_session.bootloader == "systemd-boot": From 1e2213bb82430928c8f346762c6f88457376cd30 Mon Sep 17 00:00:00 2001 From: sxmourai Date: Thu, 18 May 2023 18:20:43 +0200 Subject: [PATCH 07/17] Added wlogout support (and swaylock) --- .../default_profiles/desktops/hyprland.py | 69 ++++++++++++++++--- 1 file changed, 58 insertions(+), 11 deletions(-) diff --git a/archinstall/default_profiles/desktops/hyprland.py b/archinstall/default_profiles/desktops/hyprland.py index fb9d24f808..fd380632aa 100644 --- a/archinstall/default_profiles/desktops/hyprland.py +++ b/archinstall/default_profiles/desktops/hyprland.py @@ -157,6 +157,45 @@ class FileManager(Enum): color: #fdf6e3; }""" +WLOGOUT_CONFIG = """# PRECONFIGURED BY ARCHINSTALL +# INSPIRED BY SOLDOESTECH : https://github.com/SolDoesTech/HyprV2/blob/main/wlogout/layout +{ + "label" : "lock", + "action" : "swaylock", + "text" : "Lock" +} + +{ + "label" : "hibernate", + "action" : "systemctl hibernate", + "text" : "Hibernate" +} + +{ + "label" : "logout", + "action" : "hyprctl dispatch exit 0", + "text" : "Logout" +} + +{ + "label" : "shutdown", + "action" : "systemctl poweroff", + "text" : "Shutdown" +} + +{ + "label" : "suspend", + "action" : "systemctl suspend", + "text" : "Suspend" +} + +{ + "label" : "reboot", + "action" : "systemctl reboot", + "text" : "Reboot" +} +""" + def get_hypr_conf(keyboard_layout, file_manager): return HYPRLAND_CONFIG.format(kb=keyboard_layout, fm=file_manager) def get_wallpaper_conf(wallpaper_path): @@ -165,6 +204,12 @@ def get_waybar_conf(): return WAYBAR_CONFIG def get_waybar_css(): return WAYBAR_CSS +def get_wlogout_config(): + return WLOGOUT_CONFIG + +def write_config(path, content): + with open(path, "w") as f: + f.write(content) class HyprlandProfile(XorgProfile): def __init__(self): @@ -185,27 +230,29 @@ def packages(self) -> List[str]: "grim", "slurp", "hyprpaper", + "wlogout", + "swaylock" ] def post_install(self, install_session: 'Installer'): # Fix seatd install_session.arch_chroot("systemctl enable seatd") - keyboard_layout = "us" #TODO: How to get selected keyboard layout for user ? + keyboard_layout = "us" #TODO: How to get selected keyboard layout for user ? + dirs = "hypr/wallpapers", "waybar", "wlogout" for user in self.selected_users: chrooted_conf = f"/home/{user}/.config" - install_session.arch_chroot(f"mkdir {chrooted_conf}/hypr/wallpapers -p") - install_session.arch_chroot(f"mkdir {chrooted_conf}/waybar") + for dir in dirs: + install_session.arch_chroot(f"mkdir {chrooted_conf}/{dir} -p") install_session.arch_chroot(f"wget --output {chrooted_conf}/hypr/wallpapers/default_arch.jpg https://images.hdqwalls.com/wallpapers/arch-liinux-4k-t0.jpg") uconf = f"{install_session.target}{chrooted_conf}" - with open(f"{uconf}/hypr/hyprland.conf", "w") as f: - f.write(get_hypr_conf(keyboard_layout, self.file_manager.value)) - with open(f"{uconf}/hypr/hyprpaper.conf", "w") as f: - f.write(get_wallpaper_conf(f"{uconf}/hypr/wallpapers/default_arch.jpg")) - with open(f"{uconf}/waybar/config", "w") as f: - f.write(get_waybar_conf()) - with open(f"{uconf}/waybar/style.css", "w") as f: - f.write(get_waybar_css()) + + write_config(f"{uconf}/hypr/hyprland.conf", get_hypr_conf(keyboard_layout, self.file_manager.value)) + write_config(f"{uconf}/hypr/hyprpaper.conf", get_wallpaper_conf(f"{uconf}/hypr/wallpapers/default_arch.jpg")) + write_config(f"{uconf}/waybar/config", get_waybar_conf()) + write_config(f"{uconf}/waybar/style.css", get_waybar_css()) + write_config(f"{uconf}/wlogout/layout", get_wlogout_config()) + # For nvidia: # install_session.arch_chroot("pacman -Sy nvidia-dkms") # if install_session.bootloader == "systemd-boot": From b2f40b1218ae82dfe6676b8382d8a0674e5c02ee Mon Sep 17 00:00:00 2001 From: sxmourai Date: Thu, 18 May 2023 18:22:56 +0200 Subject: [PATCH 08/17] Fixed file managers printing --- archinstall/default_profiles/desktops/hyprland.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/default_profiles/desktops/hyprland.py b/archinstall/default_profiles/desktops/hyprland.py index fd380632aa..4def173041 100644 --- a/archinstall/default_profiles/desktops/hyprland.py +++ b/archinstall/default_profiles/desktops/hyprland.py @@ -285,7 +285,7 @@ def do_on_select(self): title = str(_("Configure Hyprland")) options = [] options += str(_(f"Select users ({' '.join(self.selected_users)})")) - options += str(_(f"File manager ({' '.join(self.file_managers)})")) + options += str(_(f"File manager ({self.file_manager})")) #TODO: Configure seat access (seatd / polkit) From 2dfb679d18c9c47298596c2da4584bb2c2e405f6 Mon Sep 17 00:00:00 2001 From: sxmourai Date: Thu, 18 May 2023 19:03:18 +0200 Subject: [PATCH 09/17] Starting to add a shell config... Definitely don't push this --- archinstall/lib/global_menu.py | 5 ++ archinstall/lib/interactions/general_conf.py | 49 +++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/global_menu.py b/archinstall/lib/global_menu.py index fc58a6531f..dcb8be2f0b 100644 --- a/archinstall/lib/global_menu.py +++ b/archinstall/lib/global_menu.py @@ -167,6 +167,11 @@ def setup_selection_menu_options(self): _('Automatic time sync (NTP)'), lambda preset: ask_ntp(preset), default=True) + self._menu_options['shell_custom'] = \ + Selector( + _('Shell customization'), + lambda preset: customize_shell(preset), + default=DEFAULT_SHELL) self._menu_options['__separator__'] = \ Selector('') self._menu_options['save_config'] = \ diff --git a/archinstall/lib/interactions/general_conf.py b/archinstall/lib/interactions/general_conf.py index 0338c61ebe..2e3fb8a729 100644 --- a/archinstall/lib/interactions/general_conf.py +++ b/archinstall/lib/interactions/general_conf.py @@ -1,7 +1,8 @@ from __future__ import annotations +from enum import Enum import pathlib -from typing import List, Any, Optional, TYPE_CHECKING +from typing import Dict, List, Any, Optional, TYPE_CHECKING from ..locale import list_keyboard_languages, list_timezones from ..menu import MenuSelectionType, Menu, TextInput @@ -206,3 +207,49 @@ def select_additional_repositories(preset: List[str]) -> List[str]: case MenuSelectionType.Selection: return choice.single_value return [] + +class Shells(Enum): + bash = 'bash' + zsh = 'zsh ' + fish = 'fish' +DEFAULT_SHELL = Shells.bash.value +OMZ_PLUGINS = ['fzf', 'bat', 'fd', 'tmux', 'ripgrep', 'zsh-autosuggestions', 'exa', 'asdf', 'zsh-syntax-highlighting', 'z', 'autojump', 'ranger', 'navi', 'shellfirm', 'antigen', 'zplug', 'antibody', 'zgen'] + +DEFAULT_SHELL_CONFIG = { + "shell": DEFAULT_SHELL, + "starship": False, + "oh-my-zsh":False, + "oh-my-posh":False, +} + + +def customize_shell(preset: Dict) -> Dict: + title = str(_("Customize your shell")) + options = [] + for sh in Shells: + if sh == preset['shell']: + options.append(f"{sh.value} (Current)") + else: + options.append(sh.value) + shell = Menu(title, options, False).run().value + if shell.endswith(" (Current)"): + shell = shell[:-10] + + sh_title = str(_("Configure your selected shell")) + sh_options = [] + sh_options.append( str(_(f"Prompt ({preset['prompt']})")) ) + if shell == Shells.zsh.value: + sh_title = str(_("Configure zsh")) + sh_options.append( str(_(f"Oh-my-zsh ({preset['oh-my-zsh']})")) ) + # sh_options.append( str(_(f"Plugins ({' '.join(preset['zsh_plugins'])})")) ) + #TODO: Make customizations for bash and fish + choice = Menu(sh_title, sh_options, False).run().value + if choice.startswith("Prompt "): + PROMPTS = ["starship",] + if shell == Shells.zsh.value and preset['oh-my-zsh'] == True: + PROMPTS.append("oh-my-posh") + preset['prompt'] = Menu("Select a prompt", PROMPTS, False).run().value + if shell == Shells.zsh.value and choice.startswith("Oh-my-zsh "): + omz_options = [str(_(f"Plugins ({' '.join(preset['oh-my-zsh plugins'])})"))] + if Menu("Configure oh-my-zsh", omz_options).run().value.startswith("Plugins"): + preset['oh-my-zsh plugins'] = Menu("Select the oh-my-zsh plugins you want", OMZ_PLUGINS, skip=False, multi=True, preset_values=preset["oh-my-zsh plugins"]) \ No newline at end of file From 79579084324a24b6c28d9ad75d24466ab0176c24 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 31 Jul 2023 10:15:14 +0200 Subject: [PATCH 10/17] Reverted custom-shell config (create a separate PR) --- archinstall/lib/global_menu.py | 5 -- archinstall/lib/interactions/general_conf.py | 49 +------------------- 2 files changed, 1 insertion(+), 53 deletions(-) diff --git a/archinstall/lib/global_menu.py b/archinstall/lib/global_menu.py index 117f8038e1..fb62b7b548 100644 --- a/archinstall/lib/global_menu.py +++ b/archinstall/lib/global_menu.py @@ -159,11 +159,6 @@ def setup_selection_menu_options(self): _('Automatic time sync (NTP)'), lambda preset: ask_ntp(preset), default=True) - self._menu_options['shell_custom'] = \ - Selector( - _('Shell customization'), - lambda preset: customize_shell(preset), - default=DEFAULT_SHELL) self._menu_options['__separator__'] = \ Selector('') self._menu_options['save_config'] = \ diff --git a/archinstall/lib/interactions/general_conf.py b/archinstall/lib/interactions/general_conf.py index eda55a3e6c..5c6b8b473b 100644 --- a/archinstall/lib/interactions/general_conf.py +++ b/archinstall/lib/interactions/general_conf.py @@ -1,5 +1,4 @@ from __future__ import annotations -from enum import Enum import pathlib from typing import Dict, List, Any, Optional, TYPE_CHECKING @@ -219,50 +218,4 @@ def select_additional_repositories(preset: List[str]) -> List[str]: case MenuSelectionType.Reset: return [] case MenuSelectionType.Selection: return choice.single_value - return [] - -class Shells(Enum): - bash = 'bash' - zsh = 'zsh ' - fish = 'fish' -DEFAULT_SHELL = Shells.bash.value -OMZ_PLUGINS = ['fzf', 'bat', 'fd', 'tmux', 'ripgrep', 'zsh-autosuggestions', 'exa', 'asdf', 'zsh-syntax-highlighting', 'z', 'autojump', 'ranger', 'navi', 'shellfirm', 'antigen', 'zplug', 'antibody', 'zgen'] - -DEFAULT_SHELL_CONFIG = { - "shell": DEFAULT_SHELL, - "starship": False, - "oh-my-zsh":False, - "oh-my-posh":False, -} - - -def customize_shell(preset: Dict) -> Dict: - title = str(_("Customize your shell")) - options = [] - for sh in Shells: - if sh == preset['shell']: - options.append(f"{sh.value} (Current)") - else: - options.append(sh.value) - shell = Menu(title, options, False).run().value - if shell.endswith(" (Current)"): - shell = shell[:-10] - - sh_title = str(_("Configure your selected shell")) - sh_options = [] - sh_options.append( str(_(f"Prompt ({preset['prompt']})")) ) - if shell == Shells.zsh.value: - sh_title = str(_("Configure zsh")) - sh_options.append( str(_(f"Oh-my-zsh ({preset['oh-my-zsh']})")) ) - # sh_options.append( str(_(f"Plugins ({' '.join(preset['zsh_plugins'])})")) ) - #TODO: Make customizations for bash and fish - choice = Menu(sh_title, sh_options, False).run().value - if choice.startswith("Prompt "): - PROMPTS = ["starship",] - if shell == Shells.zsh.value and preset['oh-my-zsh'] == True: - PROMPTS.append("oh-my-posh") - preset['prompt'] = Menu("Select a prompt", PROMPTS, False).run().value - if shell == Shells.zsh.value and choice.startswith("Oh-my-zsh "): - omz_options = [str(_(f"Plugins ({' '.join(preset['oh-my-zsh plugins'])})"))] - if Menu("Configure oh-my-zsh", omz_options).run().value.startswith("Plugins"): - preset['oh-my-zsh plugins'] = Menu("Select the oh-my-zsh plugins you want", OMZ_PLUGINS, skip=False, multi=True, preset_values=preset["oh-my-zsh plugins"]) \ No newline at end of file + return [] \ No newline at end of file From aaced418da142c310049955209b90ded9de817d8 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 31 Jul 2023 10:19:25 +0200 Subject: [PATCH 11/17] Removed systemd-logind, as that was just for testing the selector --- .../default_profiles/desktops/hyprland.py | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/archinstall/default_profiles/desktops/hyprland.py b/archinstall/default_profiles/desktops/hyprland.py index 86ba2c1248..f26abd0ed3 100644 --- a/archinstall/default_profiles/desktops/hyprland.py +++ b/archinstall/default_profiles/desktops/hyprland.py @@ -10,7 +10,6 @@ class SeatAccess(Enum): seatd = 'seatd' - logind = 'systemd-logind' class HyperlandProfile(XorgProfile): @@ -41,18 +40,33 @@ def services(self) -> List[str]: return [] def _ask_seat_access(self): - # need to activate seat service and add to seat group - title = str(_('Hyprland needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)')) - title += str(_('\n\nChoose an option to give Hyprland access to your hardware')) + """need to activate seat service and add to seat group""" - options = [e.value for e in SeatAccess] - default = None + # title = str(_('Hyprland needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)')) + # title += str(_('\n\nChoose an option to give Hyprland access to your hardware')) - if seat := self.custom_settings.get('seat_access', None): - default = seat + # options = [e.value for e in SeatAccess] + # default = None - choice = Menu(title, options, skip=False, preset_values=default).run() - self.custom_settings['seat_access'] = choice.single_value + # if seat := self.custom_settings.get('seat_access', None): + # default = seat + + # choice = Menu(title, options, skip=False, preset_values=default).run() + # self.custom_settings['seat_access'] = choice.single_value + # self.custom_settings['seat_access'] = SeatAccess.seatd# need to activate seat service and add to seat group + # title = str(_('Hyprland needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)')) + # title += str(_('\n\nChoose an option to give Hyprland access to your hardware')) + + # options = [e.value for e in SeatAccess] + # default = None + + # if seat := self.custom_settings.get('seat_access', None): + # default = seat + + # choice = Menu(title, options, skip=False, preset_values=default).run() + # self.custom_settings['seat_access'] = choice.single_value + + self.custom_settings['seat_access'] = SeatAccess.seatd def do_on_select(self): self._ask_seat_access() From 9b293e517135a9c99ad8a27e87a975634a25beb1 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 31 Jul 2023 10:21:56 +0200 Subject: [PATCH 12/17] Added polkit as an option for the seat. As it's a dependency of the hyprland package --- .../default_profiles/desktops/hyprland.py | 38 +++++++------------ 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/archinstall/default_profiles/desktops/hyprland.py b/archinstall/default_profiles/desktops/hyprland.py index f26abd0ed3..5383d3340f 100644 --- a/archinstall/default_profiles/desktops/hyprland.py +++ b/archinstall/default_profiles/desktops/hyprland.py @@ -1,15 +1,18 @@ from enum import Enum -from typing import List, Optional, Any, TYPE_CHECKING +from typing import List, Optional, TYPE_CHECKING, Any from archinstall.default_profiles.profile import ProfileType, GreeterType from archinstall.default_profiles.xorg import XorgProfile +from archinstall.lib.menu import Menu if TYPE_CHECKING: + from archinstall.lib.installer import Installer _: Any class SeatAccess(Enum): seatd = 'seatd' + polkit = 'polkit' class HyperlandProfile(XorgProfile): @@ -40,33 +43,18 @@ def services(self) -> List[str]: return [] def _ask_seat_access(self): - """need to activate seat service and add to seat group""" + # need to activate seat service and add to seat group + title = str(_('Hyprland needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)')) + title += str(_('\n\nChoose an option to give Hyprland access to your hardware')) - # title = str(_('Hyprland needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)')) - # title += str(_('\n\nChoose an option to give Hyprland access to your hardware')) + options = [e.value for e in SeatAccess] + default = None - # options = [e.value for e in SeatAccess] - # default = None + if seat := self.custom_settings.get('seat_access', None): + default = seat - # if seat := self.custom_settings.get('seat_access', None): - # default = seat - - # choice = Menu(title, options, skip=False, preset_values=default).run() - # self.custom_settings['seat_access'] = choice.single_value - # self.custom_settings['seat_access'] = SeatAccess.seatd# need to activate seat service and add to seat group - # title = str(_('Hyprland needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)')) - # title += str(_('\n\nChoose an option to give Hyprland access to your hardware')) - - # options = [e.value for e in SeatAccess] - # default = None - - # if seat := self.custom_settings.get('seat_access', None): - # default = seat - - # choice = Menu(title, options, skip=False, preset_values=default).run() - # self.custom_settings['seat_access'] = choice.single_value - - self.custom_settings['seat_access'] = SeatAccess.seatd + choice = Menu(title, options, skip=False, preset_values=default).run() + self.custom_settings['seat_access'] = choice.single_value def do_on_select(self): self._ask_seat_access() From 9e31046c069cfebcf056435d1ee7c63ba7056694 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 31 Jul 2023 10:22:43 +0200 Subject: [PATCH 13/17] Flake8 fix --- archinstall/lib/interactions/general_conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/interactions/general_conf.py b/archinstall/lib/interactions/general_conf.py index 5c6b8b473b..af72f323ac 100644 --- a/archinstall/lib/interactions/general_conf.py +++ b/archinstall/lib/interactions/general_conf.py @@ -1,7 +1,7 @@ from __future__ import annotations import pathlib -from typing import Dict, List, Any, Optional, TYPE_CHECKING +from typing import List, Any, Optional, TYPE_CHECKING from ..locale import list_timezones, list_keyboard_languages from ..menu import MenuSelectionType, Menu, TextInput From 1be5cd66114f33f400a74ac9e258e13bad3b3515 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 31 Jul 2023 10:26:33 +0200 Subject: [PATCH 14/17] The name change wasn't propegated to the menu --- archinstall/default_profiles/desktops/hyprland.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/default_profiles/desktops/hyprland.py b/archinstall/default_profiles/desktops/hyprland.py index 5383d3340f..40009bbabf 100644 --- a/archinstall/default_profiles/desktops/hyprland.py +++ b/archinstall/default_profiles/desktops/hyprland.py @@ -17,7 +17,7 @@ class SeatAccess(Enum): class HyperlandProfile(XorgProfile): def __init__(self): - super().__init__('Hyperland', ProfileType.DesktopEnv, description='') + super().__init__('Hyprland', ProfileType.DesktopEnv, description='') self.custom_settings = {'seat_access': None} From 9397dacdef9caf3db5c3d55406014d52906f3844 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 31 Jul 2023 10:34:04 +0200 Subject: [PATCH 15/17] Added newline at the end of general_conf.py to not alter it --- archinstall/lib/interactions/general_conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/interactions/general_conf.py b/archinstall/lib/interactions/general_conf.py index af72f323ac..14fcc3f811 100644 --- a/archinstall/lib/interactions/general_conf.py +++ b/archinstall/lib/interactions/general_conf.py @@ -218,4 +218,4 @@ def select_additional_repositories(preset: List[str]) -> List[str]: case MenuSelectionType.Reset: return [] case MenuSelectionType.Selection: return choice.single_value - return [] \ No newline at end of file + return [] From c8376f973a34b96c8f4dbc46cd6c9e03c5dada69 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 31 Jul 2023 10:38:32 +0200 Subject: [PATCH 16/17] Removed newline at the end of general_conf.py to not alter it --- archinstall/lib/interactions/general_conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/interactions/general_conf.py b/archinstall/lib/interactions/general_conf.py index 14fcc3f811..af72f323ac 100644 --- a/archinstall/lib/interactions/general_conf.py +++ b/archinstall/lib/interactions/general_conf.py @@ -218,4 +218,4 @@ def select_additional_repositories(preset: List[str]) -> List[str]: case MenuSelectionType.Reset: return [] case MenuSelectionType.Selection: return choice.single_value - return [] + return [] \ No newline at end of file From ea2ee87deefff4234802cc24a56344c4634df676 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 20 Sep 2023 10:43:58 +0200 Subject: [PATCH 17/17] Renamed the Hyprland class --- archinstall/default_profiles/desktops/hyprland.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/archinstall/default_profiles/desktops/hyprland.py b/archinstall/default_profiles/desktops/hyprland.py index 40009bbabf..f464c82848 100644 --- a/archinstall/default_profiles/desktops/hyprland.py +++ b/archinstall/default_profiles/desktops/hyprland.py @@ -15,7 +15,7 @@ class SeatAccess(Enum): polkit = 'polkit' -class HyperlandProfile(XorgProfile): +class HyprlandProfile(XorgProfile): def __init__(self): super().__init__('Hyprland', ProfileType.DesktopEnv, description='') @@ -27,7 +27,6 @@ def packages(self) -> List[str]: "hyprland", "dunst", "xdg-desktop-portal-hyprland", - "kitty", "qt5-wayland", "qt6-wayland" ] @@ -60,4 +59,4 @@ def do_on_select(self): self._ask_seat_access() def install(self, install_session: 'Installer'): - super().install(install_session) \ No newline at end of file + super().install(install_session)