#!/usr/bin/env python3 # This file is part of Ubuntu Sway Remix project # SPDX-FileCopyrightText: 2022 Aleksey Samoilov # SPDX-License-Identifier: GPL-3.0-or-later # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . import os import signal import sys import subprocess from PyQt6.QtWidgets import (QApplication, QMainWindow) from PyQt6.QtGui import QPixmap from PyQt6.QtCore import Qt from tileos_welcome.ui_mainwindow import Ui_MainWindow def get_config_home(): config_home = os.getenv('XDG_CONFIG_HOME') if os.getenv('XDG_CONFIG_HOME') else os.path.join( os.getenv("HOME"), ".config/") return config_home dir_name = os.path.dirname(__file__) config_home = get_config_home() user = os.getlogin() desktop_file = os.path.join(dir_name, "resources/tileos-welcome.desktop") autostart_dir = os.path.join(config_home, "autostart/") autostart_desktop_file = os.path.join(config_home, autostart_dir, "tileos-welcome.desktop") class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) # Background page_label = os.path.join(dir_name, "resources/label.png") page_pixmap = QPixmap(page_label).scaled(600, 300, Qt.AspectRatioMode.KeepAspectRatio) self.ui.logo.setPixmap(page_pixmap) self.ui.logo2.setPixmap(page_pixmap) # Autostart (copying tileos-welcome.desktop to ~/.config/autostart) if os.path.isfile(autostart_desktop_file): self.ui.checkAutostart.setChecked(True) # Detect running compositor and adapt Wiki button text to it if os.getenv("SWAYSOCK"): self.ui.btnWiki.setText("Sway Wiki") # Page 1 self.ui.btnGprd.clicked.connect(self.on_clicked_partition) self.ui.btnNext.clicked.connect(self.on_page_switch) self.ui.btnQuit.clicked.connect(self.exitApp) # Page 2 self.ui.btnGTK.clicked.connect(self.on_clicked_gtk_theme) self.ui.btnKvantum.clicked.connect(self.on_clicked_qt_theme) self.ui.btnDisplay.clicked.connect(self.on_clicked_display_settings) self.ui.btnInput.clicked.connect(self.on_clicked_input_settings) self.ui.btnPrev.clicked.connect(self.on_page_switch) self.ui.btnExit.clicked.connect(self.exitApp) def on_clicked_partition(self): subprocess.run("xhost +si:localuser:root && pkexec /usr/sbin/gparted && xhost -si:localuser:root &", shell=True) def on_clicked_website(self): subprocess.run("xdg-open", "https://tile-os.com") # TODO documentation link def on_clicked_tracker(self): subprocess.run("xdg-open", "https://gitlab.com/tile-os/tileos/-/issues") def on_clicked_contribute(self): subprocess.run("xdg-open", "https://gitlab.com/tile-os") def on_clicked_telegram(self): subprocess.run("xdg-open", "https://t.me/tile_os") def on_clicked_gtk_theme(self): subprocess.run("/usr/bin/nwg-look") def on_clicked_qt_theme(self): subprocess.run("/usr/bin/kvantummanager") def on_clicked_display_settings(self): subprocess.run("/usr/bin/nwg-displays") # TODO shell selector def on_clicked_input_settings(self): subprocess.run("/usr/bin/sway-input-config") # TODO software manager def on_page_switch(self): if self.ui.stackedWidget.currentIndex() == 0: self.ui.stackedWidget.setCurrentIndex(1) else: self.ui.stackedWidget.setCurrentIndex(0) def exitApp(self): self.close() def main(): app = QApplication(["Welcome to TileOS!"]) app.setDesktopFileName("tileos-welcome") win = MainWindow() win.show() sys.exit(app.exec()) if __name__ == "__main__": signal.signal(signal.SIGINT, signal.SIG_DFL) main()