fix espanso on elecrta, waybar tweaks, wol experiments
This commit is contained in:
parent
aceec1d4b5
commit
e7632cb5d3
4 changed files with 48 additions and 48 deletions
|
|
@ -11,7 +11,7 @@ TARGET_HOSTNAME = "tower.home.the.malice.zone"
|
|||
TARGET_IP = socket.gethostbyname(TARGET_HOSTNAME)
|
||||
|
||||
def remote_cmd(command):
|
||||
print(f"Executing: ssh tower '{command}'")
|
||||
print(f"Executing: ssh alisceon@tower.home.the.malice.zone '{command}'")
|
||||
response = subprocess.run(f"ssh tower '{command}'", shell=True, capture_output=True, text=True)
|
||||
return (response.returncode, response.stdout, response.stderr)
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ def weboot():
|
|||
code, stdout, stderr = remote_cmd("sudo efibootmgr -n 0000")
|
||||
if code == 0:
|
||||
code, stdout, stderr = remote_cmd("sudo reboot")
|
||||
time.sleep(60)
|
||||
time.sleep(120)
|
||||
if code != 0:
|
||||
raise RuntimeError(f"weboot failed {stderr}")
|
||||
return code, stdout, stderr
|
||||
|
|
@ -38,7 +38,7 @@ def get_os():
|
|||
return "offline"
|
||||
elif code != 0:
|
||||
raise RuntimeError(f"win_or_linux failed {stderr}")
|
||||
if "windows" in stdout.lower():
|
||||
if "tower\\alisceon" in stdout.lower():
|
||||
print("Target is running Windows")
|
||||
return "windows"
|
||||
else:
|
||||
|
|
@ -108,16 +108,20 @@ def shutdown():
|
|||
print("Shutting down target")
|
||||
match get_os():
|
||||
case "windows":
|
||||
code, stdout, stderr = remote_cmd("shutdown /s")
|
||||
code, stdout, stderr = remote_cmd("shutdown /s /t 0")
|
||||
time.sleep(30)
|
||||
return True
|
||||
case "linux":
|
||||
code, stdout, stderr = remote_cmd("sudo shutdown -h now")
|
||||
time.sleep(30)
|
||||
return True
|
||||
case "offline":
|
||||
print("Target is already offline")
|
||||
return False
|
||||
if get_os() == "offline":
|
||||
print("Target is now offline")
|
||||
return True
|
||||
else:
|
||||
print("Failed to shut down target")
|
||||
return False
|
||||
|
||||
def action_do(action):
|
||||
match action:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue