Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions persepolis/scripts/browser_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import platform
import subprocess
import sys
import json
if sys.platform == "win32":
import winreg

Expand Down Expand Up @@ -137,9 +138,8 @@ def installNativeMessageHost(browser, native_message_folder, webextension_json_c
osCommands.makeDirs(native_message_folder)

# Write native message host file
f = open(native_message_file, 'w')
f.write(str(webextension_json_connector).replace("'", "\""))
f.close()
with open(native_message_file, 'w') as f:
json.dump(webextension_json_connector, f, indent=4)
if os_type != OS.WINDOWS:

pipe_json = subprocess.Popen(['chmod', '+x', str(native_message_file)],
Expand All @@ -154,7 +154,6 @@ def installNativeMessageHost(browser, native_message_folder, webextension_json_c
json_done = False

else:
import winreg
# add the key to the windows registry
if browser in BROWSER.CHROME_FAMILY:
try:
Expand All @@ -175,7 +174,7 @@ def installNativeMessageHost(browser, native_message_folder, webextension_json_c

json_done = False

elif browser == BROWSER.FIREFOX_FAMILY:
elif browser in BROWSER.FIREFOX_FAMILY:
try:
# create pdmchromewrapper key under NativeMessagingHosts for firefox
winreg.CreateKey(winreg.HKEY_CURRENT_USER,
Expand Down Expand Up @@ -209,8 +208,8 @@ def nativeMessageHostFile(browser, intermediary):
if browser in BROWSER.CHROME_FAMILY:
webextension_json_connector["allowed_origins"] = ["chrome-extension://legimlagjjoghkoedakdjhocbeomojao/"]

# Add firefox keys
elif browser == BROWSER.FIREFOX_FAMILY:
# Add firefox family keys (includes LibreWolf)
elif browser in BROWSER.FIREFOX_FAMILY:
webextension_json_connector["allowed_extensions"] = [
"[email protected]",
"[email protected]"
Expand Down
70 changes: 58 additions & 12 deletions persepolis/scripts/persepolis.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
from copy import deepcopy
import sys
import os
import platform
import subprocess

# finding os platform
os_type, desktop_env = osAndDesktopEnvironment()
Expand Down Expand Up @@ -133,18 +135,62 @@ def setPersepolisFont(self, font, font_size, custom_font):

# color_scheme
def setPersepolisColorScheme(self, color_scheme):
self.persepolis_color_scheme = color_scheme
if color_scheme == 'Dark Fusion':
file = QFile(":/dark_style.qss")
file.open(QFile.ReadOnly | QFile.Text)
stream = QTextStream(file)
self.setStyleSheet(stream.readAll())

elif color_scheme == 'Light Fusion':
file = QFile(":/light_style.qss")
file.open(QFile.ReadOnly | QFile.Text)
stream = QTextStream(file)
self.setStyleSheet(stream.readAll())
self.persepolis_color_scheme = color_scheme
# Detect system dark theme for Breeze style on Linux
is_dark = False
if color_scheme == 'System':
if platform.system() == 'Linux':
# KDE Plasma
kde_color_scheme = os.environ.get('KDE_COLOR_SCHEME', '').lower()
if 'dark' in kde_color_scheme:
is_dark = True
# GTK
gtk_theme = os.environ.get('GTK_THEME', '').lower()
if 'dark' in gtk_theme:
is_dark = True
# Qt Platform Theme (for some setups)
qt_platform_theme = os.environ.get('QT_QPA_PLATFORMTHEME', '').lower()
if 'dark' in qt_platform_theme:
is_dark = True
# GNOME: check gsettings for color-scheme
xdg_desktop = os.environ.get('XDG_CURRENT_DESKTOP', '').lower()
if 'gnome' in xdg_desktop:
try:
result = subprocess.run([
'gsettings', 'get', 'org.gnome.desktop.interface', 'color-scheme'
], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
if 'prefer-dark' in result.stdout:
is_dark = True
except Exception:
pass
if xdg_desktop == 'kde':
# KDE: try to read color scheme from config file
kdeglobals = os.path.expanduser('~/.config/kdeglobals')
try:
with open(kdeglobals, 'r') as f:
for line in f:
if 'ColorScheme=' in line and 'dark' in line.lower():
is_dark = True
except Exception:
pass
# Use dark or light style sheet
if is_dark:
file = QFile(":/dark_style.qss")
else:
file = QFile(":/light_style.qss")
file.open(QFile.ReadOnly | QFile.Text)
stream = QTextStream(file)
self.setStyleSheet(stream.readAll())
elif color_scheme == 'Dark Fusion':
file = QFile(":/dark_style.qss")
file.open(QFile.ReadOnly | QFile.Text)
stream = QTextStream(file)
self.setStyleSheet(stream.readAll())
elif color_scheme == 'Light Fusion':
file = QFile(":/light_style.qss")
file.open(QFile.ReadOnly | QFile.Text)
stream = QTextStream(file)
self.setStyleSheet(stream.readAll())


# create terminal arguments
Expand Down