config fixes

This commit is contained in:
Zacharias-Brohn
2026-02-17 12:46:25 +01:00
parent 7d9ba3d570
commit e818ac5515
39 changed files with 888 additions and 144 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ JsonObject {
}
component FontFamily: JsonObject {
property string sans: "Rubik"
property string sans: "Segoe UI Variable Text"
property string mono: "CaskaydiaCove NF"
property string material: "Material Symbols Rounded"
property string clock: "Rubik"
-1
View File
@@ -1,5 +1,4 @@
import Quickshell.Io
import qs.Modules
import qs.Config
JsonObject {
+1
View File
@@ -1,6 +1,7 @@
import Quickshell.Io
JsonObject {
property bool autoHide: false
property Popouts popouts: Popouts {}
property list<var> entries: [
-5
View File
@@ -1,10 +1,5 @@
import Quickshell.Io
JsonObject {
property BgColors backgrounds: BgColors {}
property string schemeType: "vibrant"
component BgColors: JsonObject {
property string hover: "#15ffffff"
}
}
+315 -40
View File
@@ -2,28 +2,17 @@ pragma Singleton
import Quickshell
import Quickshell.Io
import qs.Modules
import ZShell
import QtQuick
import qs.Modules as Modules
import qs.Paths
Singleton {
id: root
property alias appCount: adapter.appCount
property alias baseBgColor: adapter.baseBgColor
property alias baseBorderColor: adapter.baseBorderColor
property alias accentColor: adapter.accentColor
property alias wallpaperPath: adapter.wallpaperPath
property alias maxWallpapers: adapter.maxWallpapers
property alias wallust: adapter.wallust
property alias workspaceWidget: adapter.workspaceWidget
property alias colors: adapter.colors
property alias gpuType: adapter.gpuType
property alias background: adapter.background
property alias useDynamicColors: adapter.useDynamicColors
property alias barConfig: adapter.barConfig
property alias transparency: adapter.transparency
property alias baseFont: adapter.baseFont
property alias animScale: adapter.animScale
property alias lock: adapter.lock
property alias idle: adapter.idle
property alias overview: adapter.overview
property alias services: adapter.services
property alias notifs: adapter.notifs
@@ -32,41 +21,327 @@ Singleton {
property alias general: adapter.general
property alias dashboard: adapter.dashboard
property alias appearance: adapter.appearance
property alias autoHide: adapter.autoHide
property alias macchiato: adapter.macchiato
property alias osd: adapter.osd
property alias launcher: adapter.launcher
property alias colors: adapter.colors
function save(): void {
saveTimer.restart();
recentlySaved = true;
recentSaveCooldown.restart();
}
property bool recentlySaved: false
ElapsedTimer {
id: timer
}
Timer {
running: true
interval: 5000
repeat: false
onTriggered: {
root.save();
}
}
Timer {
id: saveTimer
interval: 500
onTriggered: {
timer.restart();
try {
let config = {};
try {
config = JSON.parse(fileView.text());
} catch (e) {
config = {};
}
config = root.serializeConfig();
fileView.setText(JSON.stringify(config, null, 4));
} catch (e) {
Toaster.toast(qsTr("Failed to serialize config"), e.message, "settings_alert", Toast.Error);
}
}
}
Timer {
id: recentSaveCooldown
interval: 2000
onTriggered: {
root.recentlySaved = false;
}
}
function serializeConfig(): var {
return {
barConfig: serializeBar(),
lock: serializeLock(),
general: serializeGeneral(),
services: serializeServices(),
notifs: serializeNotifs(),
sidebar: serializeSidebar(),
utilities: serializeUtilities(),
dashboard: serializeDashboard(),
appearance: serializeAppearance(),
osd: serializeOsd(),
background: serializeBackground(),
launcher: serializeLauncher(),
colors: serializeColors()
}
}
function serializeBar(): var {
return {
autoHide: barConfig.autoHide,
popouts: {
tray: barConfig.popouts.tray,
audio: barConfig.popouts.audio,
activeWindow: barConfig.popouts.activeWindow,
resources: barConfig.popouts.resources,
clock: barConfig.popouts.clock,
network: barConfig.popouts.network,
upower: barConfig.popouts.upower
},
entries: barConfig.entries
}
}
function serializeLock(): var {
return {
recolorLogo: lock.recolorLogo,
enableFprint: lock.enableFprint,
maxFprintTries: lock.maxFprintTries,
sizes: {
heightMult: lock.sizes.heightMult,
ratio: lock.sizes.ratio,
centerWidth: lock.sizes.centerWidth
}
};
}
function serializeGeneral(): var {
return {
logo: general.logo,
wallpaperPath: general.wallpaperPath,
wallust: general.wallust,
idle: {
timouts: general.idle.timeouts
}
}
}
function serializeServices(): var {
return {
weatherLocation: services.weatherLocation,
useFahrenheit: services.useFahrenheit,
useTwelveHourClock: services.useTwelveHourClock,
gpuType: services.gpuType,
audioIncrement: services.audioIncrement,
brightnessIncrement: services.brightnessIncrement,
maxVolume: services.maxVolume,
defaultPlayer: services.defaultPlayer,
playerAliases: services.playerAliases
};
}
function serializeNotifs(): var {
return {
expire: notifs.expire,
defaultExpireTimeout: notifs.defaultExpireTimeout,
clearThreshold: notifs.clearThreshold,
expandThreshold: notifs.expandThreshold,
actionOnClick: notifs.actionOnClick,
groupPreviewNum: notifs.groupPreviewNum,
sizes: {
width: notifs.sizes.width,
image: notifs.sizes.image,
badge: notifs.sizes.badge
}
};
}
function serializeSidebar(): var {
return {
enabled: sidebar.enabled,
sizes: {
width: sidebar.sizes.width
}
};
}
function serializeUtilities(): var {
return {
enabled: utilities.enabled,
maxToasts: utilities.maxToasts,
sizes: {
width: utilities.sizes.width,
toastWidth: utilities.sizes.toastWidth
},
toasts: {
configLoaded: utilities.toasts.configLoaded,
chargingChanged: utilities.toasts.chargingChanged,
gameModeChanged: utilities.toasts.gameModeChanged,
dndChanged: utilities.toasts.dndChanged,
audioOutputChanged: utilities.toasts.audioOutputChanged,
audioInputChanged: utilities.toasts.audioInputChanged,
capsLockChanged: utilities.toasts.capsLockChanged,
numLockChanged: utilities.toasts.numLockChanged,
kbLayoutChanged: utilities.toasts.kbLayoutChanged,
vpnChanged: utilities.toasts.vpnChanged,
nowPlaying: utilities.toasts.nowPlaying
},
vpn: {
enabled: utilities.vpn.enabled,
provider: utilities.vpn.provider
}
};
}
function serializeDashboard(): var {
return {
enabled: dashboard.enabled,
mediaUpdateInterval: dashboard.mediaUpdateInterval,
dragThreshold: dashboard.dragThreshold,
sizes: {
tabIndicatorHeight: dashboard.sizes.tabIndicatorHeight,
tabIndicatorSpacing: dashboard.sizes.tabIndicatorSpacing,
infoWidth: dashboard.sizes.infoWidth,
infoIconSize: dashboard.sizes.infoIconSize,
dateTimeWidth: dashboard.sizes.dateTimeWidth,
mediaWidth: dashboard.sizes.mediaWidth,
mediaProgressSweep: dashboard.sizes.mediaProgressSweep,
mediaProgressThickness: dashboard.sizes.mediaProgressThickness,
resourceProgessThickness: dashboard.sizes.resourceProgessThickness,
weatherWidth: dashboard.sizes.weatherWidth,
mediaCoverArtSize: dashboard.sizes.mediaCoverArtSize,
mediaVisualiserSize: dashboard.sizes.mediaVisualiserSize,
resourceSize: dashboard.sizes.resourceSize
}
};
}
function serializeOsd(): var {
return {
enabled: osd.enabled,
hideDelay: osd.hideDelay,
enableBrightness: osd.enableBrightness,
enableMicrophone: osd.enableMicrophone,
sizes: {
sliderWidth: osd.sizes.sliderWidth,
sliderHeight: osd.sizes.sliderHeight
}
};
}
function serializeLauncher(): var {
return {
maxAppsShown: launcher.maxAppsShown,
maxWallpapers: launcher.maxWallpapers,
wallpaperPrefix: launcher.wallpaperPrefix
}
}
function serializeBackground(): var {
return {
wallFadeDuration: background.wallFadeDuration,
enabled: background.enabled
}
}
function serializeAppearance(): var {
return {
rounding: {
scale: appearance.rounding.scale
},
spacing: {
scale: appearance.spacing.scale
},
padding: {
scale: appearance.padding.scale
},
font: {
family: {
sans: appearance.font.family.sans,
mono: appearance.font.family.mono,
material: appearance.font.family.material,
clock: appearance.font.family.clock
},
size: {
scale: appearance.font.size.scale
}
},
anim: {
mediaGifSpeedAdjustment: 300,
sessionGifSpeed: 0.7,
durations: {
scale: appearance.anim.durations.scale
}
},
transparency: {
enabled: appearance.transparency.enabled,
base: appearance.transparency.base,
layers: appearance.transparency.layers
}
};
}
function serializeColors(): var {
return {
schemeType: colors.schemeType,
}
}
FileView {
id: root
property var configRoot: Quickshell.env("HOME")
id: fileView
path: configRoot + "/.config/z-bar/config.json"
path: `${Paths.config}/config.json`
watchChanges: true
onFileChanged: reload()
onAdapterChanged: writeAdapter()
onFileChanged: {
if ( !root.recentlySaved ) {
timer.restart();
reload();
} else {
reload();
}
}
onLoaded: {
try {
JSON.parse(text());
const elapsed = timer.elapsedMs();
if ( adapter.utilities.toasts.configLoaded && !root.recentlySaved ) {
Toaster.toast(qsTr("Config loaded"), qsTr("Config loaded in %1ms").arg(elapsed), "rule_settings");
} else if ( adapter.utilities.toasts.configLoaded && root.recentlySaved ) {
Toaster.toast(qsTr("Config saved"), qsTr("Config reloaded in %1ms").arg(elapsed), "settings_alert");
}
} catch (e) {
Toaster.toast(qsTr("Failed to load config"), e.message, "settings_alert", Toast.Error);
}
}
onLoadFailed: err => {
if ( err !== FileViewError.FileNotFound )
Toaster.toast(qsTr("Failed to read config"), FileViewError.toString(err), "settings_alert", Toast.Warning);
}
onSaveFailed: err => Toaster.toast(qsTr("Failed to save config"), FileViewError.toString(err), "settings_alert", Toast.Error)
JsonAdapter {
id: adapter
property int appCount: 20
property string wallpaperPath: Quickshell.env("HOME") + "/Pictures/Wallpapers"
property string baseBgColor: "#801a1a1a"
property string baseBorderColor: "#444444"
property AccentColor accentColor: AccentColor {}
property int maxWallpapers: 7
property bool wallust: false
property WorkspaceWidget workspaceWidget: WorkspaceWidget {}
property Colors colors: Colors {}
property string gpuType: ""
property BackgroundConfig background: BackgroundConfig {}
property bool useDynamicColors: false
property BarConfig barConfig: BarConfig {}
property Transparency transparency: Transparency {}
property string baseFont: "Segoe UI Variable Text"
property real animScale: 1.0
property LockConf lock: LockConf {}
property IdleTimeout idle: IdleTimeout {}
property Overview overview: Overview {}
property Services services: Services {}
property NotifConfig notifs: NotifConfig {}
@@ -75,9 +350,9 @@ Singleton {
property General general: General {}
property DashboardConfig dashboard: DashboardConfig {}
property AppearanceConf appearance: AppearanceConf {}
property bool autoHide: false
property bool macchiato: false
property Osd osd: Osd {}
property Launcher launcher: Launcher {}
property Colors colors: Colors {}
}
}
}
-1
View File
@@ -2,7 +2,6 @@ import Quickshell.Io
JsonObject {
property bool enabled: true
property bool showOnHover: true
property int mediaUpdateInterval: 500
property int dragThreshold: 50
property Sizes sizes: Sizes {}
+3 -3
View File
@@ -88,9 +88,9 @@ Singleton {
}
component Transparency: QtObject {
readonly property bool enabled: Config.transparency.enabled
readonly property real base: Config.transparency.base - (root.light ? 0.1 : 0)
readonly property real layers: Config.transparency.layers
readonly property bool enabled: Appearance.transparency.enabled
readonly property real base: Appearance.transparency.base - (root.light ? 0.1 : 0)
readonly property real layers: Appearance.transparency.layers
}
component M3TPalette: QtObject {
+18
View File
@@ -1,5 +1,23 @@
import Quickshell.Io
import Quickshell
JsonObject {
property string logo: ""
property string wallpaperPath: Quickshell.env("HOME") + "/Pictures/Wallpapers"
property bool wallust: false
property Idle idle: Idle {}
component Idle: JsonObject {
property list<var> timeouts: [
{
timeout: 180,
idleAction: "lock"
},
{
timeout: 300,
idleAction: "dpms off",
activeAction: "dpms on"
}
]
}
}
+7
View File
@@ -0,0 +1,7 @@
import Quickshell.Io
JsonObject {
property int maxAppsShown: 10
property int maxWallpapers: 7
property string wallpaperPrefix: ">"
}
+1 -1
View File
@@ -4,7 +4,7 @@ import Quickshell
Singleton {
id: root
property real scale: Config.animScale
property real scale: Appearance.anim.durations.scale
readonly property list<real> emphasized: [0.05, 0, 2 / 15, 0.06, 1 / 6, 0.4, 5 / 24, 0.82, 0.25, 1, 1, 1]
readonly property list<real> emphasizedAccel: [0.3, 0, 0.8, 0.15, 1, 1]