mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
power: disable profile osd by default, ensure dbus activation doesnt
happen
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtCore
|
import QtCore
|
||||||
@@ -23,79 +22,79 @@ Singleton {
|
|||||||
property string profileLastPath: ""
|
property string profileLastPath: ""
|
||||||
|
|
||||||
property var fileBrowserSettings: ({
|
property var fileBrowserSettings: ({
|
||||||
"wallpaper": {
|
"wallpaper": {
|
||||||
"lastPath": "",
|
"lastPath": "",
|
||||||
"viewMode": "grid",
|
"viewMode": "grid",
|
||||||
"sortBy": "name",
|
"sortBy": "name",
|
||||||
"sortAscending": true,
|
"sortAscending": true,
|
||||||
"iconSizeIndex": 1,
|
"iconSizeIndex": 1,
|
||||||
"showSidebar": true
|
"showSidebar": true
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"lastPath": "",
|
"lastPath": "",
|
||||||
"viewMode": "grid",
|
"viewMode": "grid",
|
||||||
"sortBy": "name",
|
"sortBy": "name",
|
||||||
"sortAscending": true,
|
"sortAscending": true,
|
||||||
"iconSizeIndex": 1,
|
"iconSizeIndex": 1,
|
||||||
"showSidebar": true
|
"showSidebar": true
|
||||||
},
|
},
|
||||||
"notepad_save": {
|
"notepad_save": {
|
||||||
"lastPath": "",
|
"lastPath": "",
|
||||||
"viewMode": "list",
|
"viewMode": "list",
|
||||||
"sortBy": "name",
|
"sortBy": "name",
|
||||||
"sortAscending": true,
|
"sortAscending": true,
|
||||||
"iconSizeIndex": 1,
|
"iconSizeIndex": 1,
|
||||||
"showSidebar": true
|
"showSidebar": true
|
||||||
},
|
},
|
||||||
"notepad_load": {
|
"notepad_load": {
|
||||||
"lastPath": "",
|
"lastPath": "",
|
||||||
"viewMode": "list",
|
"viewMode": "list",
|
||||||
"sortBy": "name",
|
"sortBy": "name",
|
||||||
"sortAscending": true,
|
"sortAscending": true,
|
||||||
"iconSizeIndex": 1,
|
"iconSizeIndex": 1,
|
||||||
"showSidebar": true
|
"showSidebar": true
|
||||||
},
|
},
|
||||||
"generic": {
|
"generic": {
|
||||||
"lastPath": "",
|
"lastPath": "",
|
||||||
"viewMode": "list",
|
"viewMode": "list",
|
||||||
"sortBy": "name",
|
"sortBy": "name",
|
||||||
"sortAscending": true,
|
"sortAscending": true,
|
||||||
"iconSizeIndex": 1,
|
"iconSizeIndex": 1,
|
||||||
"showSidebar": true
|
"showSidebar": true
|
||||||
},
|
},
|
||||||
"default": {
|
"default": {
|
||||||
"lastPath": "",
|
"lastPath": "",
|
||||||
"viewMode": "list",
|
"viewMode": "list",
|
||||||
"sortBy": "name",
|
"sortBy": "name",
|
||||||
"sortAscending": true,
|
"sortAscending": true,
|
||||||
"iconSizeIndex": 1,
|
"iconSizeIndex": 1,
|
||||||
"showSidebar": true
|
"showSidebar": true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (!isGreeterMode) {
|
if (!isGreeterMode) {
|
||||||
loadCache()
|
loadCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadCache() {
|
function loadCache() {
|
||||||
_loading = true
|
_loading = true;
|
||||||
parseCache(cacheFile.text())
|
parseCache(cacheFile.text());
|
||||||
_loading = false
|
_loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCache(content) {
|
function parseCache(content) {
|
||||||
_loading = true
|
_loading = true;
|
||||||
try {
|
try {
|
||||||
if (content && content.trim()) {
|
if (content && content.trim()) {
|
||||||
const cache = JSON.parse(content)
|
const cache = JSON.parse(content);
|
||||||
|
|
||||||
wallpaperLastPath = cache.wallpaperLastPath !== undefined ? cache.wallpaperLastPath : ""
|
wallpaperLastPath = cache.wallpaperLastPath !== undefined ? cache.wallpaperLastPath : "";
|
||||||
profileLastPath = cache.profileLastPath !== undefined ? cache.profileLastPath : ""
|
profileLastPath = cache.profileLastPath !== undefined ? cache.profileLastPath : "";
|
||||||
|
|
||||||
if (cache.fileBrowserSettings !== undefined) {
|
if (cache.fileBrowserSettings !== undefined) {
|
||||||
fileBrowserSettings = cache.fileBrowserSettings
|
fileBrowserSettings = cache.fileBrowserSettings;
|
||||||
} else if (cache.fileBrowserViewMode !== undefined) {
|
} else if (cache.fileBrowserViewMode !== undefined) {
|
||||||
fileBrowserSettings = {
|
fileBrowserSettings = {
|
||||||
"wallpaper": {
|
"wallpaper": {
|
||||||
@@ -122,65 +121,60 @@ Singleton {
|
|||||||
"iconSizeIndex": 1,
|
"iconSizeIndex": 1,
|
||||||
"showSidebar": true
|
"showSidebar": true
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cache.configVersion === undefined) {
|
if (cache.configVersion === undefined) {
|
||||||
migrateFromUndefinedToV1(cache)
|
migrateFromUndefinedToV1(cache);
|
||||||
cleanupUnusedKeys()
|
cleanupUnusedKeys();
|
||||||
saveCache()
|
saveCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("CacheData: Failed to parse cache:", e.message)
|
console.warn("CacheData: Failed to parse cache:", e.message);
|
||||||
} finally {
|
} finally {
|
||||||
_loading = false
|
_loading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveCache() {
|
function saveCache() {
|
||||||
if (_loading)
|
if (_loading)
|
||||||
return
|
return;
|
||||||
cacheFile.setText(JSON.stringify({
|
cacheFile.setText(JSON.stringify({
|
||||||
"wallpaperLastPath": wallpaperLastPath,
|
"wallpaperLastPath": wallpaperLastPath,
|
||||||
"profileLastPath": profileLastPath,
|
"profileLastPath": profileLastPath,
|
||||||
"fileBrowserSettings": fileBrowserSettings,
|
"fileBrowserSettings": fileBrowserSettings,
|
||||||
"configVersion": cacheConfigVersion
|
"configVersion": cacheConfigVersion
|
||||||
}, null, 2))
|
}, null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function migrateFromUndefinedToV1(cache) {
|
function migrateFromUndefinedToV1(cache) {
|
||||||
console.info("CacheData: Migrating configuration from undefined to version 1")
|
console.info("CacheData: Migrating configuration from undefined to version 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanupUnusedKeys() {
|
function cleanupUnusedKeys() {
|
||||||
const validKeys = [
|
const validKeys = ["wallpaperLastPath", "profileLastPath", "fileBrowserSettings", "configVersion"];
|
||||||
"wallpaperLastPath",
|
|
||||||
"profileLastPath",
|
|
||||||
"fileBrowserSettings",
|
|
||||||
"configVersion"
|
|
||||||
]
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const content = cacheFile.text()
|
const content = cacheFile.text();
|
||||||
if (!content || !content.trim()) return
|
if (!content || !content.trim())
|
||||||
|
return;
|
||||||
const cache = JSON.parse(content)
|
const cache = JSON.parse(content);
|
||||||
let needsSave = false
|
let needsSave = false;
|
||||||
|
|
||||||
for (const key in cache) {
|
for (const key in cache) {
|
||||||
if (!validKeys.includes(key)) {
|
if (!validKeys.includes(key)) {
|
||||||
console.log("CacheData: Removing unused key:", key)
|
console.log("CacheData: Removing unused key:", key);
|
||||||
delete cache[key]
|
delete cache[key];
|
||||||
needsSave = true
|
needsSave = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsSave) {
|
if (needsSave) {
|
||||||
cacheFile.setText(JSON.stringify(cache, null, 2))
|
cacheFile.setText(JSON.stringify(cache, null, 2));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("CacheData: Failed to cleanup unused keys:", e.message)
|
console.warn("CacheData: Failed to cleanup unused keys:", e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,12 +188,12 @@ Singleton {
|
|||||||
watchChanges: !isGreeterMode
|
watchChanges: !isGreeterMode
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
if (!isGreeterMode) {
|
if (!isGreeterMode) {
|
||||||
parseCache(cacheFile.text())
|
parseCache(cacheFile.text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onLoadFailed: error => {
|
onLoadFailed: error => {
|
||||||
if (!isGreeterMode) {
|
if (!isGreeterMode) {
|
||||||
console.info("CacheData: No cache file found, starting fresh")
|
console.info("CacheData: No cache file found, starting fresh");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,24 @@
|
|||||||
import Quickshell
|
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
import Quickshell
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
// Clear all image cache
|
// Clear all image cache
|
||||||
function clearImageCache() {
|
function clearImageCache() {
|
||||||
Quickshell.execDetached(["rm", "-rf", Paths.stringify(
|
Quickshell.execDetached(["rm", "-rf", Paths.stringify(Paths.imagecache)]);
|
||||||
Paths.imagecache)])
|
Paths.mkdir(Paths.imagecache);
|
||||||
Paths.mkdir(Paths.imagecache)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear cache older than specified minutes
|
// Clear cache older than specified minutes
|
||||||
function clearOldCache(ageInMinutes) {
|
function clearOldCache(ageInMinutes) {
|
||||||
Quickshell.execDetached(
|
Quickshell.execDetached(["find", Paths.stringify(Paths.imagecache), "-name", "*.png", "-mmin", `+${ageInMinutes}`, "-delete"]);
|
||||||
["find", Paths.stringify(
|
|
||||||
Paths.imagecache), "-name", "*.png", "-mmin", `+${ageInMinutes}`, "-delete"])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear cache for specific size
|
// Clear cache for specific size
|
||||||
function clearCacheForSize(size) {
|
function clearCacheForSize(size) {
|
||||||
Quickshell.execDetached(
|
Quickshell.execDetached(["find", Paths.stringify(Paths.imagecache), "-name", `*@${size}x${size}.png`, "-delete"]);
|
||||||
["find", Paths.stringify(
|
|
||||||
Paths.imagecache), "-name", `*@${size}x${size}.png`, "-delete"])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get cache size in MB
|
// Get cache size in MB
|
||||||
@@ -30,8 +26,7 @@ Singleton {
|
|||||||
var process = Qt.createQmlObject(`
|
var process = Qt.createQmlObject(`
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
Process {
|
Process {
|
||||||
command: ["du", "-sm", "${Paths.stringify(
|
command: ["du", "-sm", "${Paths.stringify(Paths.imagecache)}"]
|
||||||
Paths.imagecache)}"]
|
|
||||||
running: true
|
running: true
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: {
|
onStreamFinished: {
|
||||||
@@ -40,6 +35,6 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, root)
|
`, root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,26 @@
|
|||||||
|
pragma Singleton
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Qt.labs.folderlistmodel
|
import Qt.labs.folderlistmodel
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
pragma Singleton
|
|
||||||
pragma ComponentBehavior: Bound
|
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property string _rawLocale: Qt.locale().name
|
readonly property string _rawLocale: Qt.locale().name
|
||||||
readonly property string _lang: _rawLocale.split(/[_-]/)[0]
|
readonly property string _lang: _rawLocale.split(/[_-]/)[0]
|
||||||
readonly property var _candidates: {
|
readonly property var _candidates: {
|
||||||
const fullUnderscore = _rawLocale;
|
const fullUnderscore = _rawLocale;
|
||||||
const fullHyphen = _rawLocale.replace("_", "-");
|
const fullHyphen = _rawLocale.replace("_", "-");
|
||||||
return [fullUnderscore, fullHyphen, _lang].filter(c => c && c !== "en");
|
return [fullUnderscore, fullHyphen, _lang].filter(c => c && c !== "en");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
readonly property url translationsFolder: Qt.resolvedUrl("../translations/poexports")
|
readonly property url translationsFolder: Qt.resolvedUrl("../translations/poexports")
|
||||||
|
|
||||||
property string currentLocale: "en"
|
property string currentLocale: "en"
|
||||||
property var translations: ({})
|
property var translations: ({})
|
||||||
property bool translationsLoaded: false
|
property bool translationsLoaded: false
|
||||||
|
|
||||||
property url _selectedPath: ""
|
property url _selectedPath: ""
|
||||||
|
|
||||||
@@ -32,7 +31,8 @@ Singleton {
|
|||||||
showDirs: false
|
showDirs: false
|
||||||
showDotAndDotDot: false
|
showDotAndDotDot: false
|
||||||
|
|
||||||
onStatusChanged: if (status === FolderListModel.Ready) root._pickTranslation()
|
onStatusChanged: if (status === FolderListModel.Ready)
|
||||||
|
root._pickTranslation()
|
||||||
}
|
}
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
@@ -41,73 +41,75 @@ Singleton {
|
|||||||
|
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
try {
|
try {
|
||||||
root.translations = JSON.parse(text())
|
root.translations = JSON.parse(text());
|
||||||
root.translationsLoaded = true
|
root.translationsLoaded = true;
|
||||||
console.info(`I18n: Loaded translations for '${root.currentLocale}' ` +
|
console.info(`I18n: Loaded translations for '${root.currentLocale}' ` + `(${Object.keys(root.translations).length} contexts)`);
|
||||||
`(${Object.keys(root.translations).length} contexts)`)
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(`I18n: Error parsing '${root.currentLocale}':`, e,
|
console.warn(`I18n: Error parsing '${root.currentLocale}':`, e, "- falling back to English");
|
||||||
"- falling back to English")
|
root._fallbackToEnglish();
|
||||||
root._fallbackToEnglish()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoadFailed: (error) => {
|
onLoadFailed: error => {
|
||||||
console.warn(`I18n: Failed to load '${root.currentLocale}' (${error}), ` +
|
console.warn(`I18n: Failed to load '${root.currentLocale}' (${error}), ` + "falling back to English");
|
||||||
"falling back to English")
|
root._fallbackToEnglish();
|
||||||
root._fallbackToEnglish()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _pickTranslation() {
|
function _pickTranslation() {
|
||||||
const present = new Set()
|
const present = new Set();
|
||||||
for (let i = 0; i < dir.count; i++) {
|
for (let i = 0; i < dir.count; i++) {
|
||||||
const name = dir.get(i, "fileName") // e.g. "zh_CN.json"
|
const name = dir.get(i, "fileName"); // e.g. "zh_CN.json"
|
||||||
if (name && name.endsWith(".json")) {
|
if (name && name.endsWith(".json")) {
|
||||||
present.add(name.slice(0, -5))
|
present.add(name.slice(0, -5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < _candidates.length; i++) {
|
for (let i = 0; i < _candidates.length; i++) {
|
||||||
const cand = _candidates[i]
|
const cand = _candidates[i];
|
||||||
if (present.has(cand)) {
|
if (present.has(cand)) {
|
||||||
_useLocale(cand, dir.folder + "/" + cand + ".json")
|
_useLocale(cand, dir.folder + "/" + cand + ".json");
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_fallbackToEnglish()
|
_fallbackToEnglish();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _useLocale(localeTag, fileUrl) {
|
function _useLocale(localeTag, fileUrl) {
|
||||||
currentLocale = localeTag
|
currentLocale = localeTag;
|
||||||
_selectedPath = fileUrl
|
_selectedPath = fileUrl;
|
||||||
translationsLoaded = false
|
translationsLoaded = false;
|
||||||
translations = ({})
|
translations = ({});
|
||||||
console.info(`I18n: Using locale '${localeTag}' from ${fileUrl}`)
|
console.info(`I18n: Using locale '${localeTag}' from ${fileUrl}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _fallbackToEnglish() {
|
function _fallbackToEnglish() {
|
||||||
currentLocale = "en"
|
currentLocale = "en";
|
||||||
_selectedPath = ""
|
_selectedPath = "";
|
||||||
translationsLoaded = false
|
translationsLoaded = false;
|
||||||
translations = ({})
|
translations = ({});
|
||||||
console.warn("I18n: Falling back to built-in English strings")
|
console.warn("I18n: Falling back to built-in English strings");
|
||||||
}
|
}
|
||||||
|
|
||||||
function tr(term, context) {
|
function tr(term, context) {
|
||||||
if (!translationsLoaded || !translations) return term
|
if (!translationsLoaded || !translations)
|
||||||
const ctx = context || term
|
return term;
|
||||||
if (translations[ctx] && translations[ctx][term]) return translations[ctx][term]
|
const ctx = context || term;
|
||||||
|
if (translations[ctx] && translations[ctx][term])
|
||||||
|
return translations[ctx][term];
|
||||||
for (const c in translations) {
|
for (const c in translations) {
|
||||||
if (translations[c] && translations[c][term]) return translations[c][term]
|
if (translations[c] && translations[c][term])
|
||||||
|
return translations[c][term];
|
||||||
}
|
}
|
||||||
return term
|
return term;
|
||||||
}
|
}
|
||||||
|
|
||||||
function trContext(context, term) {
|
function trContext(context, term) {
|
||||||
if (!translationsLoaded || !translations) return term
|
if (!translationsLoaded || !translations)
|
||||||
if (translations[context] && translations[context][term]) return translations[context][term]
|
return term;
|
||||||
return term
|
if (translations[context] && translations[context][term])
|
||||||
|
return translations[context][term];
|
||||||
|
return term;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
@@ -10,11 +11,11 @@ Singleton {
|
|||||||
|
|
||||||
function openModal(modal) {
|
function openModal(modal) {
|
||||||
if (!modal.allowStacking) {
|
if (!modal.allowStacking) {
|
||||||
closeAllModalsExcept(modal)
|
closeAllModalsExcept(modal);
|
||||||
}
|
}
|
||||||
if (!modal.keepPopoutsOpen) {
|
if (!modal.keepPopoutsOpen) {
|
||||||
PopoutManager.closeAllPopouts()
|
PopoutManager.closeAllPopouts();
|
||||||
}
|
}
|
||||||
TrayMenuManager.closeAllMenus()
|
TrayMenuManager.closeAllMenus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
@@ -10,15 +11,14 @@ Singleton {
|
|||||||
|
|
||||||
function showOSD(osd) {
|
function showOSD(osd) {
|
||||||
if (!osd || !osd.screen)
|
if (!osd || !osd.screen)
|
||||||
return
|
return;
|
||||||
|
const screenName = osd.screen.name;
|
||||||
const screenName = osd.screen.name
|
const currentOSD = currentOSDsByScreen[screenName];
|
||||||
const currentOSD = currentOSDsByScreen[screenName]
|
|
||||||
|
|
||||||
if (currentOSD && currentOSD !== osd) {
|
if (currentOSD && currentOSD !== osd) {
|
||||||
currentOSD.hide()
|
currentOSD.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
currentOSDsByScreen[screenName] = osd
|
currentOSDsByScreen[screenName] = osd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import QtCore
|
import QtCore
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ var SPEC = {
|
|||||||
osdIdleInhibitorEnabled: { def: true },
|
osdIdleInhibitorEnabled: { def: true },
|
||||||
osdMicMuteEnabled: { def: true },
|
osdMicMuteEnabled: { def: true },
|
||||||
osdCapsLockEnabled: { def: true },
|
osdCapsLockEnabled: { def: true },
|
||||||
osdPowerProfileEnabled: { def: true },
|
osdPowerProfileEnabled: { def: false },
|
||||||
|
|
||||||
powerActionConfirm: { def: true },
|
powerActionConfirm: { def: true },
|
||||||
powerMenuActions: { def: ["reboot", "logout", "poweroff", "lock", "suspend", "restart"] },
|
powerMenuActions: { def: ["reboot", "logout", "poweroff", "lock", "suspend", "restart"] },
|
||||||
|
|||||||
@@ -556,24 +556,17 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyLoader {
|
Loader {
|
||||||
id: powerProfileOSDLoader
|
id: powerProfileWatcherLoader
|
||||||
active: false
|
active: SettingsData.osdPowerProfileEnabled
|
||||||
|
source: "Services/PowerProfileWatcher.qml"
|
||||||
Variants {
|
|
||||||
model: SettingsData.getFilteredScreens("osd")
|
|
||||||
|
|
||||||
delegate: PowerProfileOSD {
|
|
||||||
modelData: item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Variants {
|
||||||
target: BatteryService
|
model: SettingsData.osdPowerProfileEnabled ? SettingsData.getFilteredScreens("osd") : []
|
||||||
|
|
||||||
function onPowerProfileChanged() {
|
delegate: PowerProfileOSD {
|
||||||
powerProfileOSDLoader.active = true
|
modelData: item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,30 +7,36 @@ import qs.Widgets
|
|||||||
DankOSD {
|
DankOSD {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property int currentProfile: 0
|
||||||
|
property string profileIcon: "settings"
|
||||||
|
|
||||||
osdWidth: Theme.iconSize + Theme.spacingS * 2
|
osdWidth: Theme.iconSize + Theme.spacingS * 2
|
||||||
osdHeight: Theme.iconSize + Theme.spacingS * 2
|
osdHeight: Theme.iconSize + Theme.spacingS * 2
|
||||||
autoHideInterval: 2000
|
autoHideInterval: 2000
|
||||||
enableMouseInteraction: false
|
enableMouseInteraction: false
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: BatteryService
|
target: PowerProfileWatcher
|
||||||
|
|
||||||
function onPowerProfileChanged() {
|
function onProfileChanged(profile) {
|
||||||
if (SettingsData.osdPowerProfileEnabled) {
|
if (SettingsData.osdPowerProfileEnabled) {
|
||||||
root.show()
|
root.currentProfile = profile;
|
||||||
|
root.profileIcon = Theme.getPowerProfileIcon(profile);
|
||||||
|
root.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (SettingsData.osdPowerProfileEnabled) {
|
if (SettingsData.osdPowerProfileEnabled && typeof PowerProfileWatcher !== "undefined") {
|
||||||
root.show()
|
root.currentProfile = PowerProfileWatcher.currentProfile;
|
||||||
|
root.profileIcon = Theme.getPowerProfileIcon(PowerProfileWatcher.currentProfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
content: DankIcon {
|
content: DankIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
name: typeof PowerProfiles !== "undefined" ? Theme.getPowerProfileIcon(PowerProfiles.profile) : "settings"
|
name: root.profileIcon
|
||||||
size: Theme.iconSize
|
size: Theme.iconSize
|
||||||
color: Theme.primary
|
color: Theme.primary
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,6 @@ Singleton {
|
|||||||
|
|
||||||
property bool suppressSound: true
|
property bool suppressSound: true
|
||||||
property bool previousPluggedState: false
|
property bool previousPluggedState: false
|
||||||
property int currentPowerProfile: -1
|
|
||||||
property int previousPowerProfile: -1
|
|
||||||
|
|
||||||
signal powerProfileChanged
|
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: startupTimer
|
id: startupTimer
|
||||||
@@ -24,27 +20,6 @@ Singleton {
|
|||||||
onTriggered: root.suppressSound = false
|
onTriggered: root.suppressSound = false
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: typeof PowerProfiles !== "undefined" ? PowerProfiles : null
|
|
||||||
|
|
||||||
function onProfileChanged() {
|
|
||||||
if (typeof PowerProfiles !== "undefined") {
|
|
||||||
root.previousPowerProfile = root.currentPowerProfile;
|
|
||||||
root.currentPowerProfile = PowerProfiles.profile;
|
|
||||||
if (root.previousPowerProfile !== -1) {
|
|
||||||
root.powerProfileChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
if (typeof PowerProfiles !== "undefined") {
|
|
||||||
root.currentPowerProfile = PowerProfiles.profile;
|
|
||||||
root.previousPowerProfile = PowerProfiles.profile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly property string preferredBatteryOverride: Quickshell.env("DMS_PREFERRED_BATTERY")
|
readonly property string preferredBatteryOverride: Quickshell.env("DMS_PREFERRED_BATTERY")
|
||||||
|
|
||||||
// List of laptop batteries
|
// List of laptop batteries
|
||||||
@@ -160,7 +135,7 @@ Singleton {
|
|||||||
return isCharging ? "Charging" : (isPluggedIn ? "Plugged In" : "Discharging");
|
return isCharging ? "Charging" : (isPluggedIn ? "Plugged In" : "Discharging");
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property bool suggestPowerSaver: batteryAvailable && isLowBattery && UPower.onBattery && (typeof PowerProfiles !== "undefined" && PowerProfiles.profile !== PowerProfile.PowerSaver)
|
readonly property bool suggestPowerSaver: false
|
||||||
|
|
||||||
readonly property var bluetoothDevices: {
|
readonly property var bluetoothDevices: {
|
||||||
const btDevices = [];
|
const btDevices = [];
|
||||||
|
|||||||
36
quickshell/Services/PowerProfileWatcher.qml
Normal file
36
quickshell/Services/PowerProfileWatcher.qml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
pragma Singleton
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Services.UPower
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property int currentProfile: -1
|
||||||
|
property int previousProfile: -1
|
||||||
|
|
||||||
|
signal profileChanged(int profile)
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: typeof PowerProfiles !== "undefined" ? PowerProfiles : null
|
||||||
|
|
||||||
|
function onProfileChanged() {
|
||||||
|
if (typeof PowerProfiles !== "undefined") {
|
||||||
|
root.previousProfile = root.currentProfile;
|
||||||
|
root.currentProfile = PowerProfiles.profile;
|
||||||
|
if (root.previousProfile !== -1) {
|
||||||
|
root.profileChanged(root.currentProfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (typeof PowerProfiles !== "undefined") {
|
||||||
|
root.currentProfile = PowerProfiles.profile;
|
||||||
|
root.previousProfile = PowerProfiles.profile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user