From 2f6f940b7685a04a4d883b432e13c012cbfd421a Mon Sep 17 00:00:00 2001 From: lucy Date: Thu, 14 May 2026 19:47:31 +0200 Subject: [PATCH] add ipc handlers for settings --- modules/bar/Bar.qml | 3 ++- modules/ipc/Ipc.qml | 36 ++++++++++++++++++++++++++------- modules/wallpaper/Wallpaper.qml | 3 ++- settings/Config.qml | 23 +++++++++++++++++++++ settings/settings.ini | 6 ++++++ shell.qml | 1 + widgets/StyledText.qml | 5 +++-- 7 files changed, 66 insertions(+), 11 deletions(-) create mode 100644 settings/Config.qml create mode 100644 settings/settings.ini diff --git a/modules/bar/Bar.qml b/modules/bar/Bar.qml index 2b93e65..e040bb7 100644 --- a/modules/bar/Bar.qml +++ b/modules/bar/Bar.qml @@ -3,6 +3,7 @@ import QtQuick.Layouts import Quickshell import qs +import qs.settings Variants { model: Quickshell.screens @@ -15,7 +16,7 @@ Variants { left: true right: true } - implicitHeight: 30 + implicitHeight: Config.barHeight color: Colors.base00 RowLayout { id: leftLayout diff --git a/modules/ipc/Ipc.qml b/modules/ipc/Ipc.qml index 1d180c1..c01c863 100644 --- a/modules/ipc/Ipc.qml +++ b/modules/ipc/Ipc.qml @@ -1,15 +1,37 @@ import Quickshell -import Quickshell.Hyprland import Quickshell.Io +import qs.settings IpcHandler { id: ipcHandler - target: "util" - function refreshWs() { - Hyprland.refreshWorkspaces(); + target: "config" + function setFont(newFont: string) { + Config.font = newFont; } - function refreshMon() { - Hyprland.refreshMonitors(); - Quickshell.reload(false) + + function setFontSize(newSize: int) { + Config.fontSize = newSize; + } + + function setHeight(newHeight: int) { + Config.barHeight = newHeight; + } + + function toggleFloating() { + Config.floating = !Config.floating; + } + + function setRounding(newRounding: int) { + Config.rounding = newRounding; + } + + function setWall(newWall: string) { + if (newWall.startsWith("/")) { + Config.wallpaper = "file://" + newWall; + return; + } else if (newWall.startsWith("~")) { + Config.wallpaper = Quickshell.env("HOME") + newWall; + return; + } } } diff --git a/modules/wallpaper/Wallpaper.qml b/modules/wallpaper/Wallpaper.qml index f522a11..1b16909 100644 --- a/modules/wallpaper/Wallpaper.qml +++ b/modules/wallpaper/Wallpaper.qml @@ -1,6 +1,7 @@ import Quickshell.Wayland import Quickshell import QtQuick +import qs.settings Variants { model: Quickshell.screens @@ -19,7 +20,7 @@ Variants { Image { cache: true anchors.fill: parent - source: "/home/lucy/.walls/frierensuff.png" + source: Config.wallpaper } } diff --git a/settings/Config.qml b/settings/Config.qml new file mode 100644 index 0000000..cdf7fb6 --- /dev/null +++ b/settings/Config.qml @@ -0,0 +1,23 @@ +pragma Singleton +import QtCore +import QtQuick +import Quickshell + +Singleton { + id: root + property string font: "Adwaita Mono Nerd Font Propo" + property int fontSize: 12 + property int barHeight: 30 + property int rounding: 0 + property url wallpaper: "file:///home/lucy/.walls/frierensuff.png" + property bool floating: false + Settings { + + location: Qt.resolvedUrl("file:///home/lucy/.config/quickshell/settings/settings.ini") + property alias font: root.font + property alias fontSize: root.fontSize + property alias barHeight: root.barHeight + property alias roudning: root.rounding + property alias wallpaper: root.wallpaper + } +} diff --git a/settings/settings.ini b/settings/settings.ini new file mode 100644 index 0000000..d40d0a6 --- /dev/null +++ b/settings/settings.ini @@ -0,0 +1,6 @@ +[General] +barHeight=32 +font=0xProto Nerd Font Propo +fontSize=12 +roudning=0 +wallpaper=@Variant(\0\0\0\x11\0\0\0\"file:///home/lucy/.walls/mooon.png) diff --git a/shell.qml b/shell.qml index ff64059..8a4962c 100644 --- a/shell.qml +++ b/shell.qml @@ -3,6 +3,7 @@ import Quickshell import qs.modules.bar import qs.modules.ipc import qs.modules.wallpaper +import qs.settings ShellRoot { Bar {} diff --git a/widgets/StyledText.qml b/widgets/StyledText.qml index 20599e9..6ee74f2 100644 --- a/widgets/StyledText.qml +++ b/widgets/StyledText.qml @@ -1,8 +1,9 @@ import QtQuick import qs +import qs.settings Text { - font.family: "Adwaita Mono Nerd Font Propo" - font.pixelSize: 12 + font.family: Config.font + font.pixelSize: Config.fontSize color: Colors.base07 }