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

240 lines
13 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")
2022-09-26 18:58:04 +02:00
self.builder.get_object("install_all").hide()
2022-09-25 16:59:30 +02:00
#win.connect("destroy", Gtk.main_quit)
2022-12-23 11:05:16 +01:00
### Hidden entries
self.builder.get_object("audio_box").hide()
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)
2022-09-25 16:59:30 +02:00
### Extension refresh ###
global extension_refresh
extension_refresh = True
def extension_refresh_func():
while extension_refresh == True:
2022-09-25 17:15:28 +02:00
desktop_switch = self.builder.get_object("desktop_switch")
desktop_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep ding@rastersoft.com"], shell=True, stdout=subprocess.DEVNULL)
if (desktop_output.returncode) == 0:
desktop_switch.set_active(True)
else:
2022-09-30 15:39:25 +02:00
desktop_switch.set_active(False)
2022-09-25 17:15:28 +02:00
audio_switch = self.builder.get_object("audio_switch")
audio_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep volume-mixer@evermiss.net"], shell=True, stdout=subprocess.DEVNULL)
if (audio_output.returncode) == 0:
audio_switch.set_active(True)
else:
audio_switch.set_active(False)
blur_switch = self.builder.get_object("blur_switch")
blur_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep blur-my-shell@aunetx"], shell=True, stdout=subprocess.DEVNULL)
if (blur_output.returncode) == 0:
blur_switch.set_active(True)
else:
blur_switch.set_active(False)
tray_switch = self.builder.get_object("tray_switch")
2022-09-26 18:34:46 +02:00
tray_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep appindicatorsupport@rgcjonas.gmail.com"], shell=True, stdout=subprocess.DEVNULL)
2022-09-25 17:15:28 +02:00
if (tray_output.returncode) == 0:
tray_switch.set_active(True)
else:
tray_switch.set_active(False)
workspace_switch = self.builder.get_object("workspace_switch")
workspace_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep auto-move-windows@gnome-shell-extensions.gcampax.github.com"], shell=True, stdout=subprocess.DEVNULL)
if (workspace_output.returncode) == 0:
workspace_switch.set_active(True)
else:
2022-09-30 15:39:25 +02:00
workspace_switch.set_active(False)
2022-09-25 17:15:28 +02:00
x11_switch = self.builder.get_object("x11_switch")
2022-09-26 18:59:39 +02:00
x11_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep gestureImprovements@gestures"], shell=True, stdout=subprocess.DEVNULL)
2022-09-25 17:15:28 +02:00
if (x11_output.returncode) == 0:
x11_switch.set_active(True)
else:
2022-09-30 15:39:25 +02:00
x11_switch.set_active(False)
2022-09-25 17:15:28 +02:00
clipboard_switch = self.builder.get_object("clipboard_switch")
2022-09-26 18:34:46 +02:00
clipboard_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep clipboard-history@alexsaveau.dev"], shell=True, stdout=subprocess.DEVNULL)
2022-09-25 17:15:28 +02:00
if (clipboard_output.returncode) == 0:
clipboard_switch.set_active(True)
else:
clipboard_switch.set_active(False)
supergfxctl_switch = self.builder.get_object("supergfxctl_switch")
supergfxctl_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep supergfxctl-gex@asus-linux.org"], shell=True, stdout=subprocess.DEVNULL)
if (supergfxctl_output.returncode) == 0:
supergfxctl_switch.set_active(True)
else:
supergfxctl_switch.set_active(False)
caffeine_switch = self.builder.get_object("caffeine_switch")
2022-09-27 16:49:03 +02:00
caffeine_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep caffeine@patapon.info"], shell=True, stdout=subprocess.DEVNULL)
2022-09-25 17:15:28 +02:00
if (caffeine_output.returncode) == 0:
caffeine_switch.set_active(True)
else:
caffeine_switch.set_active(False)
kde_switch = self.builder.get_object("kde_switch")
kde_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep gsconnect@andyholmes.github.io"], shell=True, stdout=subprocess.DEVNULL)
if (kde_output.returncode) == 0:
kde_switch.set_active(True)
else:
kde_switch.set_active(False)
weather_switch = self.builder.get_object("weather_switch")
weather_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep openweather-extension@jenslody.de"], shell=True, stdout=subprocess.DEVNULL)
if (weather_output.returncode) == 0:
weather_switch.set_active(True)
else:
weather_switch.set_active(False)
stats_switch = self.builder.get_object("stats_switch")
2022-09-26 18:34:46 +02:00
stats_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep freon@UshakovVasilii_Github.yahoo.com"], shell=True, stdout=subprocess.DEVNULL)
2022-09-25 17:15:28 +02:00
if (stats_output.returncode) == 0:
stats_switch.set_active(True)
else:
stats_switch.set_active(False)
hid_switch = self.builder.get_object("hid_switch")
hid_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep wireless-hid@chlumskyvaclav.gmail.com"], shell=True, stdout=subprocess.DEVNULL)
if (hid_output.returncode) == 0:
hid_switch.set_active(True)
else:
hid_switch.set_active(False)
2022-09-27 17:01:13 +02:00
pop_switch = self.builder.get_object("pop_switch")
2022-09-26 20:48:14 +02:00
pop_output = subprocess.run(["gsettings get org.gnome.shell enabled-extensions | grep pop-shell@system76.com"], shell=True, stdout=subprocess.DEVNULL)
if (pop_output.returncode) == 0:
2022-09-27 17:01:13 +02:00
pop_switch.set_active(True)
2022-09-26 20:48:14 +02:00
else:
pop_switch.set_active(False)
2022-09-27 17:01:13 +02:00
time.sleep(5.0)
2022-09-25 16:59:30 +02:00
t1 = threading.Thread(target=extension_refresh_func)
t1.start()
def extension_refresh_kill(self):
global extension_refresh
extension_refresh = False
###
win.connect("destroy", extension_refresh_kill)
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
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):
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh blue"], shell=True)
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):
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh green"], shell=True)
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):
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh yellow"], shell=True)
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):
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh orange"], shell=True)
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):
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh red"], shell=True)
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)
2022-12-23 11:49:39 +01:00
def magenta_accent_button_pressed_cb (self, widget):
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh magenta"], shell=True)
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C magenta"], 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):
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)
2022-12-23 11:49:39 +01:00
def brown_accent_button_pressed_cb (self, widget):
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh brown"], shell=True)
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C brown"], 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):
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh gray"], shell=True)
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()