diff --git a/Config/LockConf.qml b/Config/LockConf.qml index 88ad57c..3826a90 100644 --- a/Config/LockConf.qml +++ b/Config/LockConf.qml @@ -1,11 +1,10 @@ import Quickshell.Io -import Quickshell.Services.UPower JsonObject { property int blurAmount: 40 property bool enableFprint: true property int maxFprintTries: 3 - property bool lidWatch: UPower.displayDevice.isLaptopBattery + property bool lidWatch: false property bool recolorLogo: false property bool showNotifContent: false property bool showNotifIcon: true diff --git a/Daemons/LidService.qml b/Daemons/LidService.qml new file mode 100644 index 0000000..d8ccbd7 --- /dev/null +++ b/Daemons/LidService.qml @@ -0,0 +1,18 @@ +import Quickshell +import ZShell + +Scope { + id: root + + required property var lock + + + Connections { + function onLidClosing(): void { + root.lock.lock.locked = true; + } + + target: LidWatcher + } + +} diff --git a/Modules/Settings/Categories/Lockscreen.qml b/Modules/Settings/Categories/Lockscreen.qml index 3230086..ae45f8d 100644 --- a/Modules/Settings/Categories/Lockscreen.qml +++ b/Modules/Settings/Categories/Lockscreen.qml @@ -1,5 +1,6 @@ import qs.Modules.Settings.Categories.Lockscreen import qs.Modules.Settings.Controls +import qs.Helpers import qs.Config SettingsPage { @@ -63,9 +64,11 @@ SettingsPage { name: "Laptop lid watch to lock session" object: Config.lock setting: "lidWatch" + shouldBeActive: Battery.isLaptop } Separator { + shouldBeActive: Battery.isLaptop } SettingSpinBox { diff --git a/scripts/SettingsIndex.mjs b/scripts/SettingsIndex.mjs index ba5eaed..902467b 100644 --- a/scripts/SettingsIndex.mjs +++ b/scripts/SettingsIndex.mjs @@ -326,6 +326,13 @@ export const settingsIndex = [ section: "Lockscreen", keywords: ["notification", "hide", "icon"], }, + { + name: "Laptop lid watch to lock session", + category: "lockscreen", + categoryName: "Lockscreen", + section: "Lockscreen", + keywords: ["lid", "lcck", "watch", "session", "laptop"], + }, { name: "Blur amount", category: "lockscreen", diff --git a/shell.qml b/shell.qml index 2a24bbc..39c550a 100644 --- a/shell.qml +++ b/shell.qml @@ -8,7 +8,6 @@ import Quickshell import Quickshell.Services.UPower import QtQuick -import ZShell import qs.Modules import qs.Modules.Wallpaper import qs.Modules.Lock @@ -38,15 +37,6 @@ ShellRoot { id: lock } - Connections { - enabled: Config.lock.lidWatch - function onLidClosing(): void { - lock.lock.locked = true; - } - - target: LidWatcher - } - Shortcuts { } @@ -57,6 +47,13 @@ ShellRoot { Polkit { } + LazyLoader { + activeAsync: Config.lock.lidWatch && Battery.isLaptop + component: LidService { + lock: lock + } + } + LazyLoader { activeAsync: root.laptop