Skip to content

Commit 2ea3948

Browse files
authored
Create actions.py
1 parent 08427ed commit 2ea3948

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

actions.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import os
2+
import webbrowser
3+
import subprocess
4+
5+
class Actions:
6+
def __init__(self, window):
7+
self.window = window
8+
9+
def run_command_with_feedback(self, cmd):
10+
"""Uruchamianie komend z feedbackiem."""
11+
full_cmd = f"bash -c '{cmd}'"
12+
result = os.system(f"pkexec {full_cmd}")
13+
cmd_name = cmd.split('/')[-1] if '/' in cmd else cmd
14+
if result == 0:
15+
self.window.subtitle_label.set_label(f"Uruchomiono: {cmd_name}.")
16+
else:
17+
self.window.subtitle_label.set_label(f"Błąd podczas uruchamiania: {cmd_name}.")
18+
19+
def open_website(self):
20+
webbrowser.open("https://hackeros-linux-system.github.io/HackerOS-Website/Home-page.html")
21+
self.window.subtitle_label.set_label("Otworzono stronę HackerOS.")
22+
23+
def open_x(self):
24+
webbrowser.open("https://x.com/hackeros_linux")
25+
self.window.subtitle_label.set_label("Otworzono X.")
26+
27+
def open_software(self):
28+
result = os.system("gnome-software &")
29+
self.window.subtitle_label.set_label("Uruchomiono Sklep z aplikacjami.")
30+
31+
def open_changelog(self):
32+
webbrowser.open("https://hackeros-linux-system.github.io/HackerOS-Website/releases.html")
33+
self.window.subtitle_label.set_label("Otworzono Changelog.")
34+
35+
def open_system_info(self):
36+
webbrowser.open("https://hackeros-linux-system.github.io/HackerOS-Website/about-hackeros.html")
37+
self.window.subtitle_label.set_label("Otworzono Informacje o systemie.")
38+
39+
def report_bug(self):
40+
webbrowser.open("https://github.com/HackerOS-Linux-System/HackerOS-Website/issues")
41+
self.window.subtitle_label.set_label("Otworzono Zgłoś błąd.")
42+
43+
def open_forum(self):
44+
webbrowser.open("https://github.com/HackerOS-Linux-System/HackerOS-Website/discussions")
45+
self.window.subtitle_label.set_label("Otworzono Forum dyskusyjne.")
46+
47+
def update_system(self):
48+
# Otwiera terminal z komendą hacker update, potem pyta o zamknięcie
49+
terminal_cmd = 'alacritty -e bash -c "hacker update; read -p \'Chcesz zamknąć terminal? (t/n) \' answer; if [ \"$answer\" = \'t\' ]; then exit; else echo \'Terminal pozostanie otwarty.\'; read; fi"'
50+
result = os.system(terminal_cmd)
51+
if result == 0:
52+
self.window.subtitle_label.set_label("Rozpoczęto aktualizację systemu w terminalu.")
53+
else:
54+
self.window.subtitle_label.set_label("Błąd podczas uruchamiania aktualizacji systemu.")

0 commit comments

Comments
 (0)