diff --git a/custom_components/easy_computer_manager/computer/common.py b/custom_components/easy_computer_manager/computer/common.py index 258273b..27af9b8 100644 --- a/custom_components/easy_computer_manager/computer/common.py +++ b/custom_components/easy_computer_manager/computer/common.py @@ -11,8 +11,8 @@ class CommandOutput: def __init__(self, command: str, return_code: int, output: str, error: str) -> None: self.command = command self.return_code = return_code - self.output = output - self.error = error + self.output = output.strip() + self.error = error.strip() def successful(self) -> bool: return self.return_code == 0 diff --git a/custom_components/easy_computer_manager/const.py b/custom_components/easy_computer_manager/const.py index 008664d..f85ffe8 100644 --- a/custom_components/easy_computer_manager/const.py +++ b/custom_components/easy_computer_manager/const.py @@ -22,8 +22,7 @@ ACTIONS = { "linux": ["awk -F'=' '/^NAME=|^VERSION=/{gsub(/\"/, \"\", $2); printf $2\" \"}\' /etc/os-release && echo", "lsb_release -a | awk '/Description/ {print $2, $3, $4}'"] }, "desktop_environment": { - "linux": [ - "echo \"${XDG_CURRENT_DESKTOP:-${DESKTOP_SESSION:-$(basename $(grep -Eo \'exec .*(startx|xinitrc)\' ~/.xsession 2>/dev/null | awk \'{print $2}\'))}}\""], + "linux": ["for session in $(ls /usr/bin/*session 2>/dev/null); do basename $session | sed 's/-session//'; done | grep -E 'gnome|kde|xfce|mate|lxde|cinnamon|budgie|unity' | head -n 1"], "windows": ["echo Windows"] }, "shutdown": {