added autostart symlink creation
This commit is contained in:
parent
92cdce9884
commit
83510d9f01
31
welcome.py
31
welcome.py
|
@ -6,6 +6,10 @@ import os
|
|||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, Gio
|
||||
|
||||
DESKTOP_FILE = "tromjaro-welcome-app.desktop"
|
||||
DESKTOP_FILE_PATH = os.path.join("/usr/share/applications", DESKTOP_FILE)
|
||||
AUTOSTART_SYMLINK_PATH = os.path.join(os.path.expanduser("~/.config/autostart"), DESKTOP_FILE)
|
||||
|
||||
class WelcomeScreen(Gtk.Window):
|
||||
def __init__(self):
|
||||
Gtk.Window.__init__(self, title="TROMjaro Welcome")
|
||||
|
@ -81,7 +85,7 @@ class WelcomeScreen(Gtk.Window):
|
|||
header_label.set_markup("<big><b>{}</b></big>".format(self.pages[self.current_page]["title"].upper()))
|
||||
header_label.set_hexpand(True)
|
||||
if self.current_page == 0:
|
||||
header_label.set_margin_top(180)
|
||||
header_label.set_margin_top(178)
|
||||
header_label.set_margin_bottom(20)
|
||||
grid.attach(header_label, 0, 0, 2, 1)
|
||||
|
||||
|
@ -107,13 +111,14 @@ class WelcomeScreen(Gtk.Window):
|
|||
grid_row += 1
|
||||
|
||||
image_path = self.pages[self.current_page]["image_path"]
|
||||
if image_path and os.path.exists(image_path):
|
||||
image = Gtk.Image.new_from_file(image_path)
|
||||
image.set_size_request(600, 400)
|
||||
grid.attach(image, 0, grid_row, 2, 1)
|
||||
grid_row += 1
|
||||
else:
|
||||
print("Error: Image not found:", image_path)
|
||||
if image_path:
|
||||
if os.path.exists(image_path):
|
||||
image = Gtk.Image.new_from_file(image_path)
|
||||
image.set_size_request(600, 400)
|
||||
grid.attach(image, 0, grid_row, 2, 1)
|
||||
grid_row += 1
|
||||
else:
|
||||
print("Error: Image not found:", image_path)
|
||||
|
||||
if self.pages[self.current_page]["with_button"]:
|
||||
button_text = self.pages[self.current_page]["button_text"]
|
||||
|
@ -161,7 +166,7 @@ class WelcomeScreen(Gtk.Window):
|
|||
grid_row += 1
|
||||
|
||||
checkbox = Gtk.CheckButton(label="Open the Welcome Screen on every boot")
|
||||
checkbox.set_active(True)
|
||||
checkbox.set_active(self.is_autostarted())
|
||||
checkbox.connect("toggled", self.on_checkbox_toggled)
|
||||
checkbox.set_halign(Gtk.Align.CENTER)
|
||||
grid.attach(checkbox, 0, grid_row, 2, 1)
|
||||
|
@ -213,8 +218,12 @@ class WelcomeScreen(Gtk.Window):
|
|||
def on_checkbox_toggled(self, checkbox):
|
||||
if checkbox.get_active():
|
||||
print("Welcome Screen will be opened on every boot.")
|
||||
if not os.path.islink(AUTOSTART_SYMLINK_PATH):
|
||||
os.symlink(DESKTOP_FILE_PATH, AUTOSTART_SYMLINK_PATH)
|
||||
else:
|
||||
print("Welcome Screen will not be opened on every boot.")
|
||||
if os.path.islink(AUTOSTART_SYMLINK_PATH):
|
||||
os.unlink(AUTOSTART_SYMLINK_PATH)
|
||||
|
||||
def on_next_button_clicked(self, button):
|
||||
if self.current_page < len(self.pages) - 1:
|
||||
|
@ -227,6 +236,10 @@ class WelcomeScreen(Gtk.Window):
|
|||
def run_command(self, command):
|
||||
subprocess.Popen(command.split(' '), start_new_session=True)
|
||||
|
||||
def is_autostarted(self):
|
||||
return os.path.islink(AUTOSTART_SYMLINK_PATH)
|
||||
|
||||
|
||||
win = WelcomeScreen()
|
||||
win.connect("destroy", Gtk.main_quit)
|
||||
win.show_all()
|
||||
|
|
Loading…
Reference in New Issue
Block a user