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")
|
gi.require_version("Gtk", "3.0")
|
||||||
from gi.repository import Gtk, Gdk, Gio
|
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):
|
class WelcomeScreen(Gtk.Window):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Gtk.Window.__init__(self, title="TROMjaro Welcome")
|
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_markup("<big><b>{}</b></big>".format(self.pages[self.current_page]["title"].upper()))
|
||||||
header_label.set_hexpand(True)
|
header_label.set_hexpand(True)
|
||||||
if self.current_page == 0:
|
if self.current_page == 0:
|
||||||
header_label.set_margin_top(180)
|
header_label.set_margin_top(178)
|
||||||
header_label.set_margin_bottom(20)
|
header_label.set_margin_bottom(20)
|
||||||
grid.attach(header_label, 0, 0, 2, 1)
|
grid.attach(header_label, 0, 0, 2, 1)
|
||||||
|
|
||||||
|
@ -107,13 +111,14 @@ class WelcomeScreen(Gtk.Window):
|
||||||
grid_row += 1
|
grid_row += 1
|
||||||
|
|
||||||
image_path = self.pages[self.current_page]["image_path"]
|
image_path = self.pages[self.current_page]["image_path"]
|
||||||
if image_path and os.path.exists(image_path):
|
if image_path:
|
||||||
image = Gtk.Image.new_from_file(image_path)
|
if os.path.exists(image_path):
|
||||||
image.set_size_request(600, 400)
|
image = Gtk.Image.new_from_file(image_path)
|
||||||
grid.attach(image, 0, grid_row, 2, 1)
|
image.set_size_request(600, 400)
|
||||||
grid_row += 1
|
grid.attach(image, 0, grid_row, 2, 1)
|
||||||
else:
|
grid_row += 1
|
||||||
print("Error: Image not found:", image_path)
|
else:
|
||||||
|
print("Error: Image not found:", image_path)
|
||||||
|
|
||||||
if self.pages[self.current_page]["with_button"]:
|
if self.pages[self.current_page]["with_button"]:
|
||||||
button_text = self.pages[self.current_page]["button_text"]
|
button_text = self.pages[self.current_page]["button_text"]
|
||||||
|
@ -161,7 +166,7 @@ class WelcomeScreen(Gtk.Window):
|
||||||
grid_row += 1
|
grid_row += 1
|
||||||
|
|
||||||
checkbox = Gtk.CheckButton(label="Open the Welcome Screen on every boot")
|
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.connect("toggled", self.on_checkbox_toggled)
|
||||||
checkbox.set_halign(Gtk.Align.CENTER)
|
checkbox.set_halign(Gtk.Align.CENTER)
|
||||||
grid.attach(checkbox, 0, grid_row, 2, 1)
|
grid.attach(checkbox, 0, grid_row, 2, 1)
|
||||||
|
@ -213,8 +218,12 @@ class WelcomeScreen(Gtk.Window):
|
||||||
def on_checkbox_toggled(self, checkbox):
|
def on_checkbox_toggled(self, checkbox):
|
||||||
if checkbox.get_active():
|
if checkbox.get_active():
|
||||||
print("Welcome Screen will be opened on every boot.")
|
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:
|
else:
|
||||||
print("Welcome Screen will not be opened on every boot.")
|
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):
|
def on_next_button_clicked(self, button):
|
||||||
if self.current_page < len(self.pages) - 1:
|
if self.current_page < len(self.pages) - 1:
|
||||||
|
@ -227,6 +236,10 @@ class WelcomeScreen(Gtk.Window):
|
||||||
def run_command(self, command):
|
def run_command(self, command):
|
||||||
subprocess.Popen(command.split(' '), start_new_session=True)
|
subprocess.Popen(command.split(' '), start_new_session=True)
|
||||||
|
|
||||||
|
def is_autostarted(self):
|
||||||
|
return os.path.islink(AUTOSTART_SYMLINK_PATH)
|
||||||
|
|
||||||
|
|
||||||
win = WelcomeScreen()
|
win = WelcomeScreen()
|
||||||
win.connect("destroy", Gtk.main_quit)
|
win.connect("destroy", Gtk.main_quit)
|
||||||
win.show_all()
|
win.show_all()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user