2023-12-29 12:40:35 +01:00
|
|
|
"""Constants for the Easy Computer Manager integration."""
|
2023-04-04 13:44:07 +02:00
|
|
|
|
2023-12-29 12:40:35 +01:00
|
|
|
DOMAIN = "easy_computer_manager"
|
2023-04-04 13:44:07 +02:00
|
|
|
SERVICE_SEND_MAGIC_PACKET = "send_magic_packet"
|
|
|
|
SERVICE_RESTART_TO_WINDOWS_FROM_LINUX = "restart_to_windows_from_linux"
|
2023-04-06 19:15:41 +02:00
|
|
|
SERVICE_RESTART_TO_LINUX_FROM_WINDOWS = "restart_to_linux_from_windows"
|
2023-04-04 13:44:07 +02:00
|
|
|
SERVICE_PUT_COMPUTER_TO_SLEEP = "put_computer_to_sleep"
|
|
|
|
SERVICE_START_COMPUTER_TO_WINDOWS = "start_computer_to_windows"
|
2023-12-28 22:40:29 +01:00
|
|
|
SERVICE_RESTART_COMPUTER = "restart_computer"
|
|
|
|
SERVICE_CHANGE_MONITORS_CONFIG = "change_monitors_config"
|
2023-12-30 15:32:31 +01:00
|
|
|
SERVICE_STEAM_BIG_PICTURE = "steam_big_picture"
|
2023-12-30 18:45:14 +01:00
|
|
|
SERVICE_CHANGE_AUDIO_CONFIG = "change_audio_config"
|
2023-12-30 21:20:42 +01:00
|
|
|
SERVICE_DEBUG_INFO = "debug_info"
|
2024-08-25 23:20:39 +02:00
|
|
|
|
|
|
|
|
2024-08-26 17:43:15 +02:00
|
|
|
ACTIONS = {
|
2024-08-25 23:20:39 +02:00
|
|
|
"operating_system": {
|
|
|
|
"linux": ["uname"]
|
|
|
|
},
|
|
|
|
"operating_system_version": {
|
|
|
|
"windows": ['for /f "tokens=1 delims=|" %i in (\'wmic os get Name ^| findstr /B /C:"Microsoft"\') do @echo %i'],
|
|
|
|
"linux": ["awk -F'=' '/^NAME=|^VERSION=/{gsub(/\"/, \"\", $2); printf $2\" \"}\' /etc/os-release && echo", "lsb_release -a | awk '/Description/ {print $2, $3, $4}'"]
|
|
|
|
},
|
2024-08-26 20:39:22 +02:00
|
|
|
"desktop_environment": {
|
2024-08-26 20:51:33 +02:00
|
|
|
"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"],
|
2024-08-26 20:39:22 +02:00
|
|
|
"windows": ["echo Windows"]
|
|
|
|
},
|
2024-08-25 23:20:39 +02:00
|
|
|
"shutdown": {
|
|
|
|
"windows": ["shutdown /s /t 0", "wmic os where Primary=TRUE call Shutdown"],
|
2024-08-30 11:19:48 +02:00
|
|
|
"linux": ["sudo shutdown -h now", "sudo init 0", "systemctl poweroff"]
|
2024-08-25 23:20:39 +02:00
|
|
|
},
|
|
|
|
"restart": {
|
|
|
|
"windows": ["shutdown /r /t 0", "wmic os where Primary=TRUE call Reboot"],
|
2024-08-30 11:19:48 +02:00
|
|
|
"linux": ["sudo shutdown -r now", "sudo init 6", "systemctl reboot"]
|
2024-08-25 23:20:39 +02:00
|
|
|
},
|
|
|
|
"sleep": {
|
|
|
|
"windows": ["shutdown /h /t 0", "rundll32.exe powrprof.dll,SetSuspendState Sleep"],
|
2024-08-30 11:19:48 +02:00
|
|
|
"linux": ["systemctl suspend", "sudo pm-suspend"]
|
2024-08-25 23:20:39 +02:00
|
|
|
},
|
|
|
|
"get_windows_entry_grub": {
|
2024-08-30 11:19:48 +02:00
|
|
|
"linux": ["sudo cat /etc/grub2.cfg | awk -F \"'\" '/windows/ {print $2}'",
|
|
|
|
"sudo cat /etc/grub.cfg | awk -F \"'\" '/windows/ {print $2}'"]
|
2024-08-25 23:20:39 +02:00
|
|
|
},
|
|
|
|
"set_grub_entry": {
|
2024-08-26 22:14:00 +02:00
|
|
|
"linux": {
|
|
|
|
"commands": ["sudo grub-reboot %grub-entry%", "sudo grub2-reboot %grub-entry%"],
|
|
|
|
"params": ["grub-entry"],
|
|
|
|
}
|
2024-08-26 17:43:15 +02:00
|
|
|
},
|
|
|
|
"get_monitors_config": {
|
|
|
|
"linux": ["gnome-monitor-config list"]
|
2024-08-26 19:01:32 +02:00
|
|
|
},
|
2024-08-26 22:14:00 +02:00
|
|
|
"set_monitors_config": {
|
|
|
|
"linux": {
|
|
|
|
"gnome": {
|
|
|
|
"command": "gnome-monitor-config set %args%",
|
|
|
|
"params": ["args"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-08-26 19:01:32 +02:00
|
|
|
"get_speakers": {
|
2024-08-26 19:16:44 +02:00
|
|
|
"linux": ["LANG=en_US.UTF-8 pactl list sinks"]
|
2024-08-26 19:01:32 +02:00
|
|
|
},
|
|
|
|
"get_microphones": {
|
2024-08-26 19:16:44 +02:00
|
|
|
"linux": ["LANG=en_US.UTF-8 pactl list sources"]
|
2024-08-26 19:01:32 +02:00
|
|
|
},
|
2024-08-30 09:55:51 +02:00
|
|
|
"set_audio_config": {
|
|
|
|
"linux": {
|
|
|
|
"command": "LANG=en_US.UTF-8 pactl %args%",
|
|
|
|
"params": ["args"]
|
|
|
|
}
|
|
|
|
},
|
2024-08-26 19:01:32 +02:00
|
|
|
"get_bluetooth_devices": {
|
2024-08-26 22:14:00 +02:00
|
|
|
"linux": {
|
|
|
|
"command": "bluetoothctl info",
|
|
|
|
"raise_on_error": False,
|
|
|
|
}
|
2024-08-30 10:12:22 +02:00
|
|
|
},
|
|
|
|
"install_nirmcd": {
|
|
|
|
"windows": {
|
|
|
|
"command": "powershell -Command \"Invoke-WebRequest -Uri %download_url% -OutFile %install_path%\\nircmd.zip -UseBasicParsing; Expand-Archive %install_path%\\nircmd.zip -DestinationPath %install_path%; Remove-Item %install_path%\\nircmd.zip\"",
|
|
|
|
"params": ["download_url", "install_path"]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"start_steam_big_picture": {
|
|
|
|
"linux": "export WAYLAND_DISPLAY=wayland-0; export DISPLAY=:0; steam -bigpicture &",
|
|
|
|
"windows": "start steam://open/bigpicture"
|
|
|
|
},
|
|
|
|
"stop_steam_big_picture": {
|
|
|
|
"linux": "export WAYLAND_DISPLAY=wayland-0; export DISPLAY=:0; steam -shutdown &",
|
|
|
|
"windows": "C:\\Program Files (x86)\\Steam\\steam.exe -shutdown"
|
|
|
|
},
|
|
|
|
"exit_steam_big_picture": {
|
|
|
|
"linux": "", # TODO: find a way to exit steam big picture
|
|
|
|
"windows": "nircmd win close title \"Steam Big Picture Mode\""
|
|
|
|
},
|
2024-08-25 23:20:39 +02:00
|
|
|
}
|