From 6b5b3180f31b4591c7359859cf692d538b47db20 Mon Sep 17 00:00:00 2001 From: advaithm Date: Mon, 5 Apr 2021 20:46:09 +0530 Subject: add i3-wm and i3-gaps support --- profiles/i3-gaps.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 profiles/i3-gaps.py (limited to 'profiles/i3-gaps.py') diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py new file mode 100644 index 00000000..bf8227ba --- /dev/null +++ b/profiles/i3-gaps.py @@ -0,0 +1,28 @@ +import archinstall + +def _prep_function(*args, **kwargs): + """ + Magic function called by the importing installer + before continuing any further. It also avoids executing any + other code in this stage. So it's a safe way to ask the user + for more input before any other installer steps start. + """ + + # KDE requires a functioning Xorg installation. + profile = archinstall.Profile(None, 'xorg') + with profile.load_instructions(namespace='xorg.py') as imported: + if hasattr(imported, '_prep_function'): + return imported._prep_function() + else: + print('Deprecated (??): xorg profile has no _prep_function() anymore') + +if __name__ == 'i3-wm': + # Install dependency profiles + installation.install_profile('xorg') + # gaps is installed by deafult so we are overriding it here + installation.add_additional_packages("lightdm-gtk-greeter lightdm") + # install the i3 group now + i3 = archinstall.Application(installation, 'i3-gaps') + i3.install() + # Auto start lightdm for all users + installation.enable_service('lightdm') -- cgit v1.2.3-70-g09d2 From 230c5709cc56f4896c7220d768d1da0302bf2cc0 Mon Sep 17 00:00:00 2001 From: advaithm Date: Tue, 6 Apr 2021 07:21:11 +0530 Subject: added _post_install hook. --- profiles/i3-gaps.py | 10 +++++++++- profiles/i3-wm.py | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'profiles/i3-gaps.py') diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py index bf8227ba..d9469dcd 100644 --- a/profiles/i3-gaps.py +++ b/profiles/i3-gaps.py @@ -1,4 +1,4 @@ -import archinstall +import archinstall, subprocess def _prep_function(*args, **kwargs): """ @@ -16,6 +16,14 @@ def _prep_function(*args, **kwargs): else: print('Deprecated (??): xorg profile has no _prep_function() anymore') +def _post_install(*args, **kwargs): + """ + Another magic function called after the system + has been installed. + """ + print("the installation of i3 does not conatain any configuerations for the wm. in this shell you take your time should add your configuerations") + subprocess.check_call("arch-chroot /mnt",shell=True) + if __name__ == 'i3-wm': # Install dependency profiles installation.install_profile('xorg') diff --git a/profiles/i3-wm.py b/profiles/i3-wm.py index 168abb72..8b541bbf 100644 --- a/profiles/i3-wm.py +++ b/profiles/i3-wm.py @@ -1,4 +1,4 @@ -import archinstall +import archinstall, subprocess def _prep_function(*args, **kwargs): """ @@ -15,6 +15,13 @@ def _prep_function(*args, **kwargs): return imported._prep_function() else: print('Deprecated (??): xorg profile has no _prep_function() anymore') +def _post_install(*args, **kwargs): + """ + Another magic function called after the system + has been installed. + """ + print("the installation of i3-gaps does not conatain any configuerations for the wm. in this shell you should take your time to add your configuerations") + subprocess.check_call("arch-chroot /mnt",shell=True) if __name__ == 'i3-wm': # Install dependency profiles -- cgit v1.2.3-70-g09d2 From 8c5af80c93270c463944fd891002d781f2949702 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 6 Apr 2021 09:53:28 +0200 Subject: Some language correction and function handling I more or less copied the language from i3-wm as it was more correct. Also converted `print()` into `installation.log()` so that we can get some color control and end up in the debug log. Finally, I added a try/except to handle potential crashes and return return values, since otherwise this would happen every run: * https://github.com/archlinux/archinstall/pull/190/files#diff-98d75a109b5337cd7d7c948d2cfc2379bcc51be22dfa3ca6491765f0e0bcaaabR349-R355 --- profiles/i3-gaps.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'profiles/i3-gaps.py') diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py index d9469dcd..96d972e3 100644 --- a/profiles/i3-gaps.py +++ b/profiles/i3-gaps.py @@ -21,8 +21,13 @@ def _post_install(*args, **kwargs): Another magic function called after the system has been installed. """ - print("the installation of i3 does not conatain any configuerations for the wm. in this shell you take your time should add your configuerations") - subprocess.check_call("arch-chroot /mnt",shell=True) + installation.log("the installation of i3 does not conatain any configuerations for the wm. In this shell you should take your time to add your desiired configueration. Exit the shell once you are done to continue the installation.", fg="yellow") + try: + subprocess.check_call("arch-chroot /mnt",shell=True) + except subprocess.CallProcessError: + return False + + return True if __name__ == 'i3-wm': # Install dependency profiles -- cgit v1.2.3-70-g09d2 From e3ea46ce5c0fc58f142b749aec86ab97a66c0da3 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 6 Apr 2021 13:27:00 -0400 Subject: Noticed that some KDE instances weren't changed to i3 when copying Another one --- profiles/i3-gaps.py | 2 +- profiles/i3-wm.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'profiles/i3-gaps.py') diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py index 96d972e3..50511dce 100644 --- a/profiles/i3-gaps.py +++ b/profiles/i3-gaps.py @@ -8,7 +8,7 @@ def _prep_function(*args, **kwargs): for more input before any other installer steps start. """ - # KDE requires a functioning Xorg installation. + # i3 requires a functioning Xorg installation. profile = archinstall.Profile(None, 'xorg') with profile.load_instructions(namespace='xorg.py') as imported: if hasattr(imported, '_prep_function'): diff --git a/profiles/i3-wm.py b/profiles/i3-wm.py index 8b541bbf..e700997f 100644 --- a/profiles/i3-wm.py +++ b/profiles/i3-wm.py @@ -8,7 +8,7 @@ def _prep_function(*args, **kwargs): for more input before any other installer steps start. """ - # KDE requires a functioning Xorg installation. + # i3 requires a functioning Xorg installation. profile = archinstall.Profile(None, 'xorg') with profile.load_instructions(namespace='xorg.py') as imported: if hasattr(imported, '_prep_function'): -- cgit v1.2.3-70-g09d2 From 37db6b8973ef6fbb06ae72505ba836d16bd87d3d Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Thu, 8 Apr 2021 20:58:52 -0400 Subject: Add is_top_level_profile = False to i3 profiles --- profiles/i3-gaps.py | 2 ++ profiles/i3-wm.py | 2 ++ 2 files changed, 4 insertions(+) (limited to 'profiles/i3-gaps.py') diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py index 50511dce..e900117a 100644 --- a/profiles/i3-gaps.py +++ b/profiles/i3-gaps.py @@ -1,5 +1,7 @@ import archinstall, subprocess +is_top_level_profile = False + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer diff --git a/profiles/i3-wm.py b/profiles/i3-wm.py index cd6cbc81..a2449e39 100644 --- a/profiles/i3-wm.py +++ b/profiles/i3-wm.py @@ -1,5 +1,7 @@ import archinstall, subprocess +is_top_level_profile = False + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer -- cgit v1.2.3-70-g09d2 From 6a6439daa929e534fec580a39cbd69087f5f43f2 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Thu, 8 Apr 2021 21:08:17 -0400 Subject: Move more logic into common profile --- profiles/i3-gaps.py | 8 +------- profiles/i3-wm.py | 7 +------ profiles/i3.py | 9 +++++++++ 3 files changed, 11 insertions(+), 13 deletions(-) (limited to 'profiles/i3-gaps.py') diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py index e900117a..d6308ad5 100644 --- a/profiles/i3-gaps.py +++ b/profiles/i3-gaps.py @@ -31,13 +31,7 @@ def _post_install(*args, **kwargs): return True -if __name__ == 'i3-wm': - # Install dependency profiles - installation.install_profile('xorg') - # gaps is installed by deafult so we are overriding it here - installation.add_additional_packages("lightdm-gtk-greeter lightdm") +if __name__ == 'i3-gaps': # install the i3 group now i3 = archinstall.Application(installation, 'i3-gaps') i3.install() - # Auto start lightdm for all users - installation.enable_service('lightdm') diff --git a/profiles/i3-wm.py b/profiles/i3-wm.py index a2449e39..c4c05ec9 100644 --- a/profiles/i3-wm.py +++ b/profiles/i3-wm.py @@ -17,6 +17,7 @@ def _prep_function(*args, **kwargs): return imported._prep_function() else: print('Deprecated (??): xorg profile has no _prep_function() anymore') + def _post_install(*args, **kwargs): """ Another magic function called after the system @@ -31,12 +32,6 @@ def _post_install(*args, **kwargs): return True if __name__ == 'i3-wm': - # Install dependency profiles - installation.install_profile('xorg') - # we are installing lightdm to auto start i3 - installation.add_additional_packages("lightdm-gtk-greeter lightdm") # install the i3 group now i3 = archinstall.Application(installation, 'i3-wm') i3.install() - # Auto start lightdm for all users - installation.enable_service('lightdm') diff --git a/profiles/i3.py b/profiles/i3.py index b9d7495e..c08f4d89 100644 --- a/profiles/i3.py +++ b/profiles/i3.py @@ -49,6 +49,15 @@ if __name__ == 'i3': # Install common packages for all i3 configurations installation.add_additional_packages(__packages__) + # Install dependency profiles + installation.install_profile('xorg') + + # gaps is installed by deafult so we are overriding it here + installation.add_additional_packages("lightdm-gtk-greeter lightdm") + + # Auto start lightdm for all users + installation.enable_service('lightdm') + # TODO: Remove magic variable 'installation' and place it # in archinstall.storage or archinstall.session/archinstall.installation installation.install_profile(archinstall.storage['_desktop_profile']) -- cgit v1.2.3-70-g09d2 From 7e161d187ced4275365cb958d8f066b697bcc141 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Thu, 8 Apr 2021 21:20:00 -0400 Subject: Remove post-install hooks from i3 profiles --- profiles/i3-gaps.py | 13 ------------- profiles/i3-wm.py | 13 ------------- 2 files changed, 26 deletions(-) (limited to 'profiles/i3-gaps.py') diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py index d6308ad5..395e69f6 100644 --- a/profiles/i3-gaps.py +++ b/profiles/i3-gaps.py @@ -18,19 +18,6 @@ def _prep_function(*args, **kwargs): else: print('Deprecated (??): xorg profile has no _prep_function() anymore') -def _post_install(*args, **kwargs): - """ - Another magic function called after the system - has been installed. - """ - installation.log("the installation of i3 does not conatain any configuerations for the wm. In this shell you should take your time to add your desiired configueration. Exit the shell once you are done to continue the installation.", fg="yellow") - try: - subprocess.check_call("arch-chroot /mnt",shell=True) - except subprocess.CallProcessError: - return False - - return True - if __name__ == 'i3-gaps': # install the i3 group now i3 = archinstall.Application(installation, 'i3-gaps') diff --git a/profiles/i3-wm.py b/profiles/i3-wm.py index c4c05ec9..4c3135e5 100644 --- a/profiles/i3-wm.py +++ b/profiles/i3-wm.py @@ -18,19 +18,6 @@ def _prep_function(*args, **kwargs): else: print('Deprecated (??): xorg profile has no _prep_function() anymore') -def _post_install(*args, **kwargs): - """ - Another magic function called after the system - has been installed. - """ - installation.log("the installation of i3 does not conatain any configuerations for the wm. In this shell you should take your time to add your desiired configueration. Exit the shell once you are done to continue the installation.", fg="yellow") - try: - subprocess.check_call("arch-chroot /mnt",shell=True) - except subprocess.CallProcessError: - return False - - return True - if __name__ == 'i3-wm': # install the i3 group now i3 = archinstall.Application(installation, 'i3-wm') -- cgit v1.2.3-70-g09d2 From 82c5241946ec96223aebe6453c58845182290fbb Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Thu, 8 Apr 2021 21:23:29 -0400 Subject: This might work to make the i3 profiles as small as possible --- profiles/i3-gaps.py | 9 +-------- profiles/i3-wm.py | 9 +-------- profiles/i3.py | 10 +++++++++- 3 files changed, 11 insertions(+), 17 deletions(-) (limited to 'profiles/i3-gaps.py') diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py index 395e69f6..ddca34b7 100644 --- a/profiles/i3-gaps.py +++ b/profiles/i3-gaps.py @@ -9,14 +9,7 @@ def _prep_function(*args, **kwargs): other code in this stage. So it's a safe way to ask the user for more input before any other installer steps start. """ - - # i3 requires a functioning Xorg installation. - profile = archinstall.Profile(None, 'xorg') - with profile.load_instructions(namespace='xorg.py') as imported: - if hasattr(imported, '_prep_function'): - return imported._prep_function() - else: - print('Deprecated (??): xorg profile has no _prep_function() anymore') + return True if __name__ == 'i3-gaps': # install the i3 group now diff --git a/profiles/i3-wm.py b/profiles/i3-wm.py index 4c3135e5..4a0415fc 100644 --- a/profiles/i3-wm.py +++ b/profiles/i3-wm.py @@ -9,14 +9,7 @@ def _prep_function(*args, **kwargs): other code in this stage. So it's a safe way to ask the user for more input before any other installer steps start. """ - - # i3 requires a functioning Xorg installation. - profile = archinstall.Profile(None, 'xorg') - with profile.load_instructions(namespace='xorg.py') as imported: - if hasattr(imported, '_prep_function'): - return imported._prep_function() - else: - print('Deprecated (??): xorg profile has no _prep_function() anymore') + return True if __name__ == 'i3-wm': # install the i3 group now diff --git a/profiles/i3.py b/profiles/i3.py index c08f4d89..9f58e7eb 100644 --- a/profiles/i3.py +++ b/profiles/i3.py @@ -18,12 +18,20 @@ def _prep_function(*args, **kwargs): supported_configurations = ['i3-wm', 'i3-gaps'] desktop = archinstall.generic_select(supported_configurations, 'Select your desired configuration: ') - + # Temporarily store the selected desktop profile # in a session-safe location, since this module will get reloaded # the next time it gets executed. archinstall.storage['_desktop_profile'] = desktop + # i3 requires a functioning Xorg installation. + profile = archinstall.Profile(None, 'xorg') + with profile.load_instructions(namespace='xorg.py') as imported: + if hasattr(imported, '_prep_function'): + return imported._prep_function() + else: + print('Deprecated (??): xorg profile has no _prep_function() anymore') + profile = archinstall.Profile(None, desktop) # Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered. with profile.load_instructions(namespace=f"{desktop}.py") as imported: -- cgit v1.2.3-70-g09d2