Skip to content

Commit

Permalink
Merge pull request #498 from RedBearAK/dev_beta
Browse files Browse the repository at this point in the history
Too many things to name
  • Loading branch information
RedBearAK authored Jan 25, 2025
2 parents c2f762a + 6280428 commit f3afd77
Show file tree
Hide file tree
Showing 25 changed files with 1,032 additions and 329 deletions.
88 changes: 77 additions & 11 deletions README.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions cosmic-dbus-service/toshy_cosmic_dbus_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def __init__(self):

self.wdw_handles_dct = {}
self.cosmic_to_foreign_map = {}
self.active_foreign_handle = None
self.active_app_class = ERR_NO_COSMIC_APP_CLASS
self.active_wdw_title = ERR_NO_COSMIC_WDW_TITLE

Expand Down Expand Up @@ -278,11 +279,17 @@ def handle_app_id_change(self, handle, app_id):
if handle not in self.wdw_handles_dct:
self.wdw_handles_dct[handle] = {}
self.wdw_handles_dct[handle]['app_id'] = app_id
# Deal with possible out-of-order Wayland events
if handle == self.active_foreign_handle:
self.active_app_class = app_id

def handle_title_change(self, handle, title):
if handle not in self.wdw_handles_dct:
self.wdw_handles_dct[handle] = {}
self.wdw_handles_dct[handle]['title'] = title
# Deal with possible out-of-order Wayland events
if handle == self.active_foreign_handle:
self.active_wdw_title = title

def handle_window_closed(self, handle):
"""Remove window from local state."""
Expand Down Expand Up @@ -340,6 +347,7 @@ def handle_state_change(self, handle, states_bytes):
if ZcosmicToplevelHandleV1.state.activated.value in state_values:

if self.cosmic_protocol_ver >= 2:
self.active_foreign_handle = foreign_handle
self.active_app_class = self.wdw_handles_dct[foreign_handle]['app_id']
self.active_wdw_title = self.wdw_handles_dct[foreign_handle]['title']

Expand Down
32 changes: 22 additions & 10 deletions lib/env_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import Dict

# ENV_CONTEXT module version:
__version__ = '20241210'
__version__ = '20250118'

VERBOSE = True
FLUSH = True
Expand Down Expand Up @@ -105,8 +105,13 @@ def read_release_files(self) -> Dict[str, str]:
return contents

def is_process_running(self, process_name):
"""Utility function to check if process is running, case-insensitive where supported"""
cmd = ['pgrep', '-x', '-i', process_name]
if self.DISTRO_ID == "centos" and self.DISTRO_VER == "7":
# CentOS 7 complains about "-i" being invalid option, so remove it
cmd = ['pgrep', '-x', process_name]
try:
subprocess.check_output(['pgrep', '-x', process_name])
subprocess.check_output(cmd)
return True
except subprocess.CalledProcessError:
return False
Expand Down Expand Up @@ -342,6 +347,11 @@ def get_desktop_environment(self):
os.environ.get("DESKTOP_SESSION")
)

# If it's a colon-separated list in XDG_CURRENT_DESKTOP,
# the first entry is the primary desktop environment
if _desktop_env and ':' in _desktop_env:
_desktop_env = _desktop_env.split(':')[0]

# Check for Qtile if the environment variables were not set/empty
if not _desktop_env and self.is_qtile_running():
_desktop_env = 'qtile'
Expand Down Expand Up @@ -546,24 +556,26 @@ def get_window_manager(self):
# Older GNOME may have 'mutter' integrated into 'gnome-shell' process
'gnome': [
'mutter',
'gnome-shell'
'gnome-shell',
],

# LXQt often uses OpenBox, but can use a number of different WMs in X11 or Wayland
'lxqt': [
'openbox',
'labwc',
'sway',
'hyprland',
'kwin_wayland',
'wayfire',
'river'
'openbox', # X11/Xorg window manager
'labwc', # Wayland compositor
'sway', # Wayland compositor
'hyprland', # Wayland compositor
'kwin_wayland', # Wayland compositor
'wayfire', # Wayland compositor
'river', # Wayland compositor
'niri', # Wayland compositor
],

'awesome': 'awesome',
'cinnamon': 'cinnamon',
'cosmic': 'cosmic-comp',
'dwm': 'dwm',
'hyprland': 'Hyprland', # the process name is capitalized (this is unusual)
'i3': 'i3',
'i3-gaps': 'i3',
'miracle-wm': 'miracle-wm',
Expand Down
3 changes: 3 additions & 0 deletions scripts/bin/toshy-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ fi
# shellcheck disable=SC1091
source "$HOME/.config/toshy/.venv/bin/activate"

# Set the process name for the Toshy Preferences GUI app launcher process
echo "toshy-pref-stub" > /proc/$$/comm

python3 "$HOME/.config/toshy/toshy_gui.py"
8 changes: 8 additions & 0 deletions scripts/bin/toshy-services-disable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ else
fi


# This script is pointless if the system doesn't support "user" systemd services (e.g., CentOS 7)
if ! systemctl --user list-unit-files &>/dev/null; then
echo "ERROR: Systemd user services are probably not supported here."
echo
exit 1
fi


echo -e "\nDisabling Toshy systemd services..."

systemctl --user disable toshy-cosmic-dbus.service
Expand Down
8 changes: 8 additions & 0 deletions scripts/bin/toshy-services-enable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ else
fi


# This script is pointless if the system doesn't support "user" systemd services (e.g., CentOS 7)
if ! systemctl --user list-unit-files &>/dev/null; then
echo "ERROR: Systemd user services are probably not supported here."
echo
exit 1
fi


echo -e "\nRe-enabling Toshy systemd services..."

systemctl --user reenable toshy-cosmic-dbus.service
Expand Down
44 changes: 37 additions & 7 deletions scripts/bin/toshy-services-log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ if [[ $EUID -eq 0 ]]; then
exit 1
fi

# # Check if $USER and $HOME environment variables are not empty
# if [[ -z $USER ]] || [[ -z $HOME ]]; then
# echo "\$USER and/or \$HOME environment variables are not set. We need them."
# exit 1
# fi


# Check if systemd is actually the init system
if [[ $(ps -p 1 -o comm=) == "systemd" ]]; then
Expand Down Expand Up @@ -52,6 +46,10 @@ trap 'clean_exit' SIGINT
echo "Showing systemd journal messages for Toshy services (since last boot):"


# Set the process name for the Toshy services log process
echo "toshy-svcs-log" > /proc/$$/comm


# Check if stdbuf is available and set the appropriate command
# Hopefully this may stop certain terminals from holding back journal
# output and showing new output in large bursts.
Expand All @@ -66,4 +64,36 @@ fi
# -n100 to show the last 100 lines (max) of existing log output
# journalctl --user -n100 -b -f -u toshy-config -u toshy-session-monitor -u toshy-kde-dbus
# newer(?) syntax to do the same thing?
${STDBUF_CMD} journalctl -n100 -b -f --user-unit 'toshy-*'
# ${STDBUF_CMD} journalctl -n100 -b -f --user-unit 'toshy-*'

# Had trouble with Tumbleweed not wanting to show any output at all when using the wildcard, so...

# Start building the command with the basic parameters
cmd_base="${STDBUF_CMD} journalctl -n200 -b -f"

# First get all the Toshy service names into an array
# Backslashes not required inside parentheses in bash?
if systemctl --user list-unit-files &>/dev/null; then
mapfile -t toshy_services < <(
systemctl --user list-unit-files |
grep -i toshy |
grep -v generated |
awk '{print $1}'
)
else
# Handle systems without user service support (e.g., CentOS 7)
echo "ERROR: Systemd user services are probably not supported here."
echo
exit 1
fi

# Add each service to the base command
cmd_units=""
for service in "${toshy_services[@]}"; do
cmd_units+=" --user-unit $service"
done

# Combine and execute
full_cmd="${cmd_base}${cmd_units}"
# echo "Executing: $full_cmd"
eval "$full_cmd"
8 changes: 8 additions & 0 deletions scripts/bin/toshy-services-restart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ else
fi


# This script is pointless if the system doesn't support "user" systemd services (e.g., CentOS 7)
if ! systemctl --user list-unit-files &>/dev/null; then
echo "ERROR: Systemd user services are probably not supported here."
echo
exit 1
fi


echo -e "\nRestarting Toshy systemd services..."

systemctl --user restart toshy-cosmic-dbus.service
Expand Down
8 changes: 8 additions & 0 deletions scripts/bin/toshy-services-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ else
fi


# This script is pointless if the system doesn't support "user" systemd services (e.g., CentOS 7)
if ! systemctl --user list-unit-files &>/dev/null; then
echo "ERROR: Systemd user services are probably not supported here."
echo
exit 1
fi


echo -e "\nStarting Toshy systemd services..."

systemctl --user start toshy-cosmic-dbus.service
Expand Down
7 changes: 7 additions & 0 deletions scripts/bin/toshy-services-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ else
exit 0
fi

# This script is pointless if the system doesn't support "user" systemd services (e.g., CentOS 7)
if ! systemctl --user list-unit-files &>/dev/null; then
echo "ERROR: Systemd user services are probably not supported here."
echo
exit 1
fi


export SYSTEMD_PAGER=""

Expand Down
8 changes: 8 additions & 0 deletions scripts/bin/toshy-services-stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ else
fi


# This script is pointless if the system doesn't support "user" systemd services (e.g., CentOS 7)
if ! systemctl --user list-unit-files &>/dev/null; then
echo "ERROR: Systemd user services are probably not supported here."
echo
exit 1
fi


echo "Stopping Toshy systemd services..."

systemctl --user stop toshy-cosmic-dbus.service
Expand Down
8 changes: 8 additions & 0 deletions scripts/bin/toshy-systemd-remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ else
fi


# This script is pointless if the system doesn't support "user" systemd services (e.g., CentOS 7)
if ! systemctl --user list-unit-files &>/dev/null; then
echo "ERROR: Systemd user services are probably not supported here."
echo
exit 1
fi



LOCAL_BIN_PATH="$HOME/.local/bin"
USER_SYSD_PATH="$HOME/.config/systemd/user"
Expand Down
9 changes: 9 additions & 0 deletions scripts/bin/toshy-systemd-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ else
exit 0
fi


# This script is pointless if the system doesn't support "user" systemd services (e.g., CentOS 7)
if ! systemctl --user list-unit-files &>/dev/null; then
echo "ERROR: Systemd user services are probably not supported here."
echo
exit 1
fi


LOCAL_BIN_PATH="$HOME/.local/bin"
USER_SYSD_PATH="$HOME/.config/systemd/user"
TOSHY_CFG_PATH="$HOME/.config/toshy"
Expand Down
3 changes: 3 additions & 0 deletions scripts/bin/toshy-tray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ fi
# shellcheck disable=SC1091
source "$HOME/.config/toshy/.venv/bin/activate"

# Set the process name for the Toshy Tray app launcher process
echo "toshy-tray-stub" > /proc/$$/comm

python3 "$HOME/.config/toshy/toshy_tray.py"
Loading

0 comments on commit f3afd77

Please sign in to comment.