mirror of
https://github.com/kittywitch/konawall-py.git
synced 2026-02-09 04:19:19 -08:00
feat: kde fixes, icon, logging
This commit is contained in:
parent
bfb74c7aca
commit
a461bf400f
5 changed files with 64 additions and 15 deletions
|
|
@ -1,16 +1,55 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import dbus
|
||||||
from konawall.module_loader import add_environment
|
from konawall.module_loader import add_environment
|
||||||
|
|
||||||
|
# https://powersnail.com/2023/set-plasma-wallpaper/
|
||||||
|
|
||||||
|
SCRIPT_GET_DESKTOPS = """
|
||||||
|
function getDesktops() {
|
||||||
|
return desktops()
|
||||||
|
.filter(d => d.screen != -1)
|
||||||
|
.sort((a, b) => screenGeometry(a.screen).left - screenGeometry(b.screen).left);
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
SCRIPT_SET_WALLPAPER = """
|
||||||
|
function setWallpaper(desktop, path) {
|
||||||
|
desktop.wallpaperPlugin = "org.kde.image"
|
||||||
|
desktop.currentConfigGroup = Array("Wallpaper", "org.kde.image", "General")
|
||||||
|
desktop.writeConfig("Image", path)
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
SCRIPT_ALL = f"""
|
||||||
|
{SCRIPT_GET_DESKTOPS}
|
||||||
|
{SCRIPT_SET_WALLPAPER}
|
||||||
|
const imageList = IMAGE_LIST;
|
||||||
|
getDesktops().forEach((desktop, i) => setWallpaper(desktop, imageList[i % imageList.length]));
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
SCRIPT_ONE = f"""
|
||||||
|
{SCRIPT_GET_DESKTOPS}
|
||||||
|
{SCRIPT_SET_WALLPAPER}
|
||||||
|
setWallpaper(getDesktops()[DESKTOP_ID], IMAGE);
|
||||||
|
"""
|
||||||
"""
|
"""
|
||||||
This sets the wallpaper on KDE.
|
This sets the wallpaper on KDE.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def quote(s):
|
||||||
|
return "'" + s + "'"
|
||||||
|
|
||||||
|
def plasma_dbus():
|
||||||
|
bus = dbus.SessionBus()
|
||||||
|
plasma = dbus.Interface(
|
||||||
|
bus.get_object("org.kde.plasmashell", "/PlasmaShell"), dbus_interface="org.kde.PlasmaShell"
|
||||||
|
)
|
||||||
|
return plasma
|
||||||
|
|
||||||
|
|
||||||
@add_environment("kde_setter")
|
@add_environment("kde_setter")
|
||||||
def set_wallpapers(files: list, displays: list):
|
def set_wallpapers(files: list, displays: list):
|
||||||
for file in files:
|
image_list_string = "[" + ",".join(quote(p) for p in files) + "]"
|
||||||
kde_script = f"""
|
script = SCRIPT_ALL.replace("IMAGE_LIST", image_list_string)
|
||||||
for (const desktop of desktops()) {{
|
plasma_dbus().evaluateScript(script)
|
||||||
desktop.currentConfigGroup = ["Wallpaper", "org.kde.image", "General"]
|
|
||||||
desktop.writeConfig("Image", "{file}")
|
|
||||||
}}
|
|
||||||
"""
|
|
||||||
subprocess.run(["qdbus", "org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell.evaluateScript", kde_script])
|
|
||||||
|
|
@ -70,10 +70,7 @@ class Konawall(wx.adv.TaskBarIcon):
|
||||||
height = 128
|
height = 128
|
||||||
|
|
||||||
# Missing texture style, magenta and black checkerboard
|
# Missing texture style, magenta and black checkerboard
|
||||||
image = Image.new('RGB', (width, height), (0, 0, 0))
|
image = Image.open(os.path.join(os.path.dirname(__file__), 'icon.png'))
|
||||||
dc = ImageDraw.Draw(image)
|
|
||||||
dc.rectangle((0, 0, width//2, height//2), fill=(255, 0, 255))
|
|
||||||
dc.rectangle((width//2, height//2, width, height), fill=(255, 0, 255))
|
|
||||||
if "wxMSW" in wx.PlatformInfo:
|
if "wxMSW" in wx.PlatformInfo:
|
||||||
image = image.resize((16, 16))
|
image = image.resize((16, 16))
|
||||||
elif "wxGTK" in wx.PlatformInfo:
|
elif "wxGTK" in wx.PlatformInfo:
|
||||||
|
|
@ -331,7 +328,18 @@ def main():
|
||||||
except:
|
except:
|
||||||
version = "testing version"
|
version = "testing version"
|
||||||
|
|
||||||
file_logger = logging.FileHandler("app.log", mode="a")
|
if wx.Platform == "__WXGTK__":
|
||||||
|
from xdg_base_dirs import xdg_config_home
|
||||||
|
log_path = os.path.join(xdg_config_home(), "konawall", "log.toml")
|
||||||
|
if wx.Platform == "__WXMAC__":
|
||||||
|
log_path_string = "~/Library/Application Support/konawall/log.toml"
|
||||||
|
log_path = os.path.expanduser(log_path_string)
|
||||||
|
elif wx.Platform == "__WXMSW__":
|
||||||
|
log_path_string = "%APPDATA%\\konawall\\log.toml"
|
||||||
|
log_path = os.path.expandvars(log_path_string)
|
||||||
|
else:
|
||||||
|
log_path = os.path.join(os.path.expanduser("~"), ".config", "konawall", "log.toml")
|
||||||
|
file_logger = logging.FileHandler(log_path, mode="a")
|
||||||
console_logger = logging.StreamHandler()
|
console_logger = logging.StreamHandler()
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.DEBUG,
|
level=logging.DEBUG,
|
||||||
|
|
|
||||||
BIN
konawall/icon.png
Normal file
BIN
konawall/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
|
|
@ -18,7 +18,7 @@ in
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
|
||||||
propagatedBuildInputs = let
|
propagatedBuildInputs = let
|
||||||
dependencyNames = lib.attrNames poetryBlock.dependencies;
|
dependencyNames = (lib.attrNames poetryBlock.dependencies) ++ ["dbus-python"];
|
||||||
dependencies = map (name: python311Packages.${name} or dependencyReplacements.${name}) dependencyNames;
|
dependencies = map (name: python311Packages.${name} or dependencyReplacements.${name}) dependencyNames;
|
||||||
in
|
in
|
||||||
dependencies;
|
dependencies;
|
||||||
|
|
|
||||||
4
setup.py
4
setup.py
|
|
@ -1,4 +1,4 @@
|
||||||
from setuptools import setup
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
with open("README.MD", "r") as f:
|
with open("README.MD", "r") as f:
|
||||||
long_description = f.read()
|
long_description = f.read()
|
||||||
|
|
@ -16,6 +16,8 @@ setup(
|
||||||
author_email = poetryBlock["authors"][0].split(" <")[1][:-1],
|
author_email = poetryBlock["authors"][0].split(" <")[1][:-1],
|
||||||
description = poetryBlock["description"],
|
description = poetryBlock["description"],
|
||||||
long_description = long_description,
|
long_description = long_description,
|
||||||
|
package_data={'': ['*.png', '*.jpg', '*.jpeg', '*.gif', '*.bmp', '*.tiff', '*.webp']},
|
||||||
|
include_package_data=True,
|
||||||
entry_points = {
|
entry_points = {
|
||||||
"console_scripts": [
|
"console_scripts": [
|
||||||
"konawall = konawall.gui:main",
|
"konawall = konawall.gui:main",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue