pika-gnome-layouts/usr/lib/pika/gnome-layouts/main.py

151 lines
7.0 KiB
Python
Raw Normal View History

2022-09-23 19:59:44 +02:00
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gio
import subprocess
import os
import os.path
from pathlib import Path
2022-09-25 16:59:30 +02:00
import time
import threading
2022-09-23 19:59:44 +02:00
class Application:
### MAIN WINDOW ###
def __init__(self):
self.column_names = False
self.drop_nan = False
self.df = None
2022-12-23 11:05:16 +01:00
application_id="org.pika.layouts"
2022-09-23 19:59:44 +02:00
self.builder = Gtk.Builder()
2022-12-23 11:05:16 +01:00
self.builder.add_from_file("/usr/lib/pika/gnome-layouts/main.ui")
2022-09-23 19:59:44 +02:00
self.builder.connect_signals(self)
win = self.builder.get_object("main_window")
2023-03-29 15:24:50 +02:00
2022-12-23 11:05:16 +01:00
2022-09-25 17:21:59 +02:00
### Enable Extensions
subprocess.run(["gsettings set org.gnome.shell disable-user-extensions false"], shell=True, stdout=subprocess.DEVNULL)
2023-03-24 16:32:55 +01:00
accent_box = self.builder.get_object("accent_box")
2023-03-24 16:28:59 +01:00
2023-03-24 17:15:19 +01:00
accent_output = subprocess.run(["dconf read /org/pika/layouts/pika-theme | grep 1"], shell=True)
2023-03-24 16:28:59 +01:00
2023-03-24 17:15:19 +01:00
if (accent_output.returncode) != 0:
2023-03-24 16:32:55 +01:00
accent_box.hide()
2023-03-24 16:28:59 +01:00
2023-03-29 15:24:50 +02:00
### Window props ###
2022-09-25 16:59:30 +02:00
2022-09-23 19:59:44 +02:00
win.connect("destroy", Gtk.main_quit)
self.window = self.builder.get_object("main_window")
self.window.show()
2022-12-23 11:07:53 +01:00
settings = Gio.Settings.new("org.pika.layouts")
2022-09-23 19:59:44 +02:00
2023-03-24 16:54:44 +01:00
### Themes
2023-03-24 16:56:09 +01:00
def on_pika_theme_button_pressed(self, widget):
2023-03-24 17:15:19 +01:00
accent_box = self.builder.get_object("accent_box")
2023-03-24 16:56:09 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/theme.sh pika"], shell=True)
accent_box.show()
def on_gnome_theme_button_pressed(self, widget):
2023-03-24 17:15:19 +01:00
accent_box = self.builder.get_object("accent_box")
2023-03-24 16:56:09 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/theme.sh gnome"], shell=True)
accent_box.hide()
2023-03-24 16:54:44 +01:00
2022-09-23 19:59:44 +02:00
2022-09-24 10:54:47 +02:00
if settings.get_int("layout-num") == 1:
win10toggle = self.builder.get_object("win10_button")
win10toggle.set_active(True)
2022-09-23 19:59:44 +02:00
2022-09-24 10:54:47 +02:00
if settings.get_int("layout-num") == 2:
win11toggle = self.builder.get_object("win11_button")
win11toggle.set_active(True)
if settings.get_int("layout-num") == 3:
gnometoggle = self.builder.get_object("gnome_button")
gnometoggle.set_active(True)
if settings.get_int("layout-num") == 4:
macostoggle = self.builder.get_object("macos_button")
macostoggle.set_active(True)
2022-09-27 20:59:58 +02:00
if settings.get_int("layout-num") == 5:
macostoggle = self.builder.get_object("gnome2_button")
macostoggle.set_active(True)
if settings.get_int("layout-num") == 6:
macostoggle = self.builder.get_object("unity_button")
macostoggle.set_active(True)
2022-09-24 09:16:59 +02:00
2022-09-24 10:57:25 +02:00
### Layouts ###
def on_win10_button_pressed(self, widget):
2022-12-23 11:07:53 +01:00
settings = Gio.Settings.new("org.pika.layouts")
2022-09-24 10:57:25 +02:00
settings.set_int("layout-num", 1)
2022-12-23 14:09:20 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/layout-scripts/win10.sh"], shell=True)
2022-09-24 10:57:25 +02:00
def on_win11_button_pressed(self, widget):
2022-12-23 11:07:53 +01:00
settings = Gio.Settings.new("org.pika.layouts")
2022-09-24 10:57:25 +02:00
settings.set_int("layout-num", 2)
2022-12-23 14:09:20 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/layout-scripts/win11.sh"], shell=True)
2022-09-24 10:57:25 +02:00
def on_gnome_button_pressed(self, widget):
2022-12-23 11:07:53 +01:00
settings = Gio.Settings.new("org.pika.layouts")
2022-09-24 10:57:25 +02:00
settings.set_int("layout-num", 3)
2022-12-23 14:09:20 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/layout-scripts/reset.sh"], shell=True)
2022-09-24 10:57:25 +02:00
def on_macos_button_pressed(self, widget):
2022-12-23 11:07:53 +01:00
settings = Gio.Settings.new("org.pika.layouts")
2022-09-24 10:57:25 +02:00
settings.set_int("layout-num", 4)
2022-12-23 14:09:20 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/layout-scripts/macos.sh"], shell=True)
2022-09-27 20:59:58 +02:00
def on_gnome2_button_pressed(self, widget):
2022-12-23 11:07:53 +01:00
settings = Gio.Settings.new("org.pika.layouts")
2022-09-27 20:59:58 +02:00
settings.set_int("layout-num", 5)
2022-12-23 14:09:20 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/layout-scripts/gnome2.sh"], shell=True)
2022-09-27 20:59:58 +02:00
def on_unity_button_pressed(self, widget):
2022-12-23 11:07:53 +01:00
settings = Gio.Settings.new("org.pika.layouts")
2022-09-27 20:59:58 +02:00
settings.set_int("layout-num", 6)
2022-12-23 14:09:20 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/layout-scripts/unity.sh"], shell=True)
2022-09-24 10:57:25 +02:00
### Settings ###
2022-12-23 11:49:39 +01:00
### Accent Colors
def blue_accent_button_pressed_cb (self, widget):
2023-03-24 17:25:56 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh Blue"], shell=True)
2022-12-23 11:49:39 +01:00
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C blue"], shell=True)
2022-12-23 12:08:12 +01:00
subprocess.run(["echo 'theme change done!'"], shell=True)
2022-12-23 11:49:39 +01:00
def green_accent_button_pressed_cb (self, widget):
2023-03-24 17:25:56 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh Green"], shell=True)
2022-12-23 11:49:39 +01:00
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C green"], shell=True)
2022-12-23 12:08:12 +01:00
subprocess.run(["echo 'theme change done!'"], shell=True)
2022-12-23 11:49:39 +01:00
def yellow_accent_button_pressed_cb (self, widget):
2023-03-24 17:25:56 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh Yellow"], shell=True)
2022-12-23 11:49:39 +01:00
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C yellow"], shell=True)
2022-12-23 12:08:12 +01:00
subprocess.run(["echo 'theme change done!'"], shell=True)
2022-12-23 11:49:39 +01:00
def orange_accent_button_pressed_cb (self, widget):
2023-03-24 17:25:56 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh Orange"], shell=True)
2022-12-23 11:49:39 +01:00
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C orange"], shell=True)
2022-12-23 12:08:12 +01:00
subprocess.run(["echo 'theme change done!'"], shell=True)
2022-12-23 11:49:39 +01:00
def red_accent_button_pressed_cb (self, widget):
2023-03-24 17:25:56 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh Red"], shell=True)
2022-12-23 11:49:39 +01:00
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C red"], shell=True)
2022-12-23 12:08:12 +01:00
subprocess.run(["echo 'theme change done!'"], shell=True)
2023-03-24 17:25:56 +01:00
def pink_accent_button_pressed_cb (self, widget):
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh Pink"], shell=True)
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C pink"], shell=True)
2022-12-23 12:08:12 +01:00
subprocess.run(["echo 'theme change done!'"], shell=True)
2022-12-23 11:49:39 +01:00
def purple_accent_button_pressed_cb (self, widget):
2023-03-24 17:25:56 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh Purple"], shell=True)
2022-12-23 12:08:12 +01:00
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C violet"], shell=True)
subprocess.run(["echo 'theme change done!'"], shell=True)
2023-03-24 17:25:56 +01:00
def teal_accent_button_pressed_cb (self, widget):
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh Teal"], shell=True)
2023-03-25 14:17:53 +01:00
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C teal"], shell=True)
2022-12-23 12:08:12 +01:00
subprocess.run(["echo 'theme change done!'"], shell=True)
2022-12-23 11:49:39 +01:00
def gray_accent_button_pressed_cb (self, widget):
2023-03-25 14:17:53 +01:00
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh Grey"], shell=True)
2022-12-23 11:49:39 +01:00
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C grey"], shell=True)
2022-12-23 12:08:12 +01:00
subprocess.run(["echo 'theme change done!'"], shell=True)
2022-09-24 13:45:53 +02:00
2022-09-23 19:59:44 +02:00
Application()
Gtk.main()