Skip to content

Commit

Permalink
Merge pull request #499 from RedBearAK/dev_beta
Browse files Browse the repository at this point in the history
LXQt, miriway, venv command logging
  • Loading branch information
RedBearAK authored Jan 26, 2025
2 parents f3afd77 + 5f2a5ec commit ac54fc0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
8 changes: 5 additions & 3 deletions default-toshy-config/toshy_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,15 @@
# the keymapper.
known_wlroots_compositors = [
'hyprland',
'labwc', # untested but should work
'labwc',
'miracle-wm',
'miriway',
'miriway-shell', # actual process name for 'miriway' compositor?
'niri',
'qtile',
'river', # untested but should work
'river',
'sway',
'wayfire', # untested but should work
'wayfire',
]

# Make sure the 'wlroots_compositors' list variable exists before checking it.
Expand Down
24 changes: 21 additions & 3 deletions lib/env_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ def get_desktop_environment(self):
'MATE': 'mate',
'Miracle-WM': 'miracle-wm',
'miracle-wm:mir': 'miracle-wm',
'Miriway': 'miriway',
'Niri': 'niri',
'Pantheon': 'pantheon',
'Plasma': 'kde',
Expand Down Expand Up @@ -492,6 +493,8 @@ def get_desktop_env_version(self):
self.DE_MAJ_VER = self.get_gnome_version()
elif self.DESKTOP_ENV == 'kde':
self.DE_MAJ_VER = self.get_kde_version()
elif self.DESKTOP_ENV == 'lxqt':
self.DE_MAJ_VER = self.get_lxqt_version()

if not self.DE_MAJ_VER:
self.DE_MAJ_VER = 'no_logic_for_DE'
Expand Down Expand Up @@ -527,6 +530,16 @@ def get_kde_version(self):
# no 'kpackagetool' command in KDE 3?
return 'kde_ver_check_err'

def get_lxqt_version(self):
try:
output = subprocess.check_output(["lxqt-session", "--version"]).decode().strip()
match = re.search(r"lxqt-session (\d+\.\d+\.\d+)", output)
if match:
major_version = match.group(1).split('.')[0]
return major_version
except subprocess.CalledProcessError:
return 'lxqt_ver_check_err'

####################################################################################################
## ##
## ██ ██ ██ ███ ██ ██████ ██████ ██ ██ ███ ███ ██████ ██████ ##
Expand Down Expand Up @@ -569,6 +582,8 @@ def get_window_manager(self):
'wayfire', # Wayland compositor
'river', # Wayland compositor
'niri', # Wayland compositor
'miriway', # Wayland compositor
'miriway-shell', # Wayland compositor (actual process name?)
],

'awesome': 'awesome',
Expand Down Expand Up @@ -620,10 +635,13 @@ def get_lxqt_window_manager(self):
try:
with open(config_path, 'r') as config_file:
for line in config_file:
if line.startswith('window_manager='):
if line.startswith('window_manager=') or line.startswith('compositor='):
# Typically the line would be like "window_manager=openbox\n"
wm_name = line.strip().split('=')[1]
if self.is_process_running(wm_name):
wm_name = os.path.basename(line.strip().split('=')[1])
if wm_name == 'miriway' and self.is_process_running('miriway-shell'):
self.WINDOW_MGR = 'miriway-shell'
return
elif self.is_process_running(wm_name):
self.WINDOW_MGR = wm_name
return
else:
Expand Down
17 changes: 15 additions & 2 deletions setup_toshy.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def __init__(self) -> None:

@property
def venv_cmd_lst(self):
# Originally a class instance attribute varaible:
# Originally a class instance attribute variable:
# self.venv_cmd_lst = [self.py_interp_path, '-m', 'venv', self.venv_path]
# Needs to re-evaluate itself when accessed, in case Python interpreter path changed:
return [self.py_interp_path, '-m', 'venv', self.venv_path]
Expand Down Expand Up @@ -2333,28 +2333,41 @@ def handle_venv_quirks_Tumbleweed(self):

def setup_python_vir_env():
"""Setup a virtual environment to install Python packages"""
print(f'\n\n§ Setting up the Python virtual environment...\n{cnfg.separator}')
venv_quirks_handler = PythonVenvQuirksHandler()

print(f'\n\n§ Setting up the Python virtual environment...\n{cnfg.separator}')

# Create the virtual environment if it doesn't exist
if not os.path.exists(cnfg.venv_path):

if cnfg.DISTRO_ID in distro_groups_map['leap-based']:
venv_quirks_handler.handle_venv_quirks_Leap()

elif cnfg.DISTRO_ID in distro_groups_map['tumbleweed-based']:
venv_quirks_handler.handle_venv_quirks_Tumbleweed()

elif cnfg.DISTRO_ID == 'centos' and cnfg.distro_mjr_ver == '7':
venv_quirks_handler.handle_venv_quirks_CentOS_7()

elif cnfg.DISTRO_ID == 'centos' and cnfg.distro_mjr_ver == '8':
venv_quirks_handler.handle_venv_quirks_CentOS_Stream_8()

elif cnfg.DISTRO_ID in distro_groups_map['rhel-based']:
venv_quirks_handler.handle_venv_quirks_RHEL()

try:
print(f'Using Python version {cnfg.py_interp_ver_str}.')
print(f'Full venv command: {" ".join(cnfg.venv_cmd_lst)}')

subprocess.run(cnfg.venv_cmd_lst, check=True)

# Strange behavior on OpenMandriva req's re-running the same command. Weird but true.
if cnfg.DISTRO_ID in ['openmandriva']:
venv_quirks_handler.handle_venv_quirks_OpenMandriva(cnfg.venv_cmd_lst)
except subprocess.CalledProcessError as proc_err:
error(f'ERROR: Problem creating the Python virtual environment:\n\t{proc_err}')
safe_shutdown(1)

# We do not need to "activate" the venv right now, just create it
print(f'Python virtual environment setup complete.')
print(f"Location: '{cnfg.venv_path}'")
Expand Down

0 comments on commit ac54fc0

Please sign in to comment.