Cli tool #9
@@ -5,6 +5,7 @@ import Quickshell.Io
|
|||||||
import ZShell
|
import ZShell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import qs.Modules as Modules
|
import qs.Modules as Modules
|
||||||
|
import qs.Helpers
|
||||||
import qs.Paths
|
import qs.Paths
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
@@ -126,6 +127,8 @@ Singleton {
|
|||||||
wallust: general.color.wallust,
|
wallust: general.color.wallust,
|
||||||
mode: general.color.mode,
|
mode: general.color.mode,
|
||||||
schemeGeneration: general.color.schemeGeneration,
|
schemeGeneration: general.color.schemeGeneration,
|
||||||
|
scheduleDarkStart: general.color.scheduleDarkStart,
|
||||||
|
scheduleDarkEnd: general.color.scheduleDarkEnd
|
||||||
},
|
},
|
||||||
apps: {
|
apps: {
|
||||||
terminal: general.apps.terminal,
|
terminal: general.apps.terminal,
|
||||||
@@ -332,6 +335,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
|
ModeScheduler.checkStartup();
|
||||||
try {
|
try {
|
||||||
JSON.parse(text());
|
JSON.parse(text());
|
||||||
const elapsed = timer.elapsedMs();
|
const elapsed = timer.elapsedMs();
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ JsonObject {
|
|||||||
property bool wallust: false
|
property bool wallust: false
|
||||||
property bool schemeGeneration: true
|
property bool schemeGeneration: true
|
||||||
property string mode: "dark"
|
property string mode: "dark"
|
||||||
|
property int scheduleDarkStart: 0
|
||||||
|
property int scheduleDarkEnd: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
component Apps: JsonObject {
|
component Apps: JsonObject {
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import Quickshell
|
||||||
|
import QtQuick
|
||||||
|
import qs.Modules
|
||||||
|
import qs.Helpers
|
||||||
|
import qs.Config
|
||||||
|
import qs.Paths
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
readonly property int darkStart: Config.general.color.scheduleDarkStart
|
||||||
|
readonly property int darkEnd: Config.general.color.scheduleDarkEnd
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: darkModeTimer
|
||||||
|
|
||||||
|
interval: 5000
|
||||||
|
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
onTriggered: {
|
||||||
|
if ( darkStart === darkEnd )
|
||||||
|
return;
|
||||||
|
var now = new Date();
|
||||||
|
if ( now.getHours() >= darkStart || now.getHours() < darkEnd ) {
|
||||||
|
if ( DynamicColors.light )
|
||||||
|
applyDarkMode();
|
||||||
|
} else {
|
||||||
|
if ( !DynamicColors.light )
|
||||||
|
applyLightMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyDarkMode() {
|
||||||
|
if ( Config.general.color.schemeGeneration ) {
|
||||||
|
Quickshell.execDetached(["zshell-cli", "scheme", "generate", "--image-path", `${WallpaperPath.currentWallpaperPath}`, "--thumbnail-path", `${Paths.cache}/imagecache/thumbnail.jpg`, "--output", `${Paths.state}/scheme.json`, "--scheme", `${Config.colors.schemeType}`, "--mode", "dark"]);
|
||||||
|
} else {
|
||||||
|
Quickshell.execDetached(["zshell-cli", "scheme", "generate", "--preset", `${DynamicColors.scheme}:${DynamicColors.flavour}`, "--output", `${Paths.state}/scheme.json`, "--mode", "dark"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Config.general.color.mode = "dark";
|
||||||
|
|
||||||
|
Quickshell.execDetached(["gsettings", "set", "org.gnome.desktop.interface", "color-scheme", "'prefer-dark'"])
|
||||||
|
|
||||||
|
Quickshell.execDetached(["sh", "-c", `sed -i 's/color_scheme_path=\\(.*\\)Light.colors/color_scheme_path=\\1Dark.colors/' ${Paths.home}/.config/qt6ct/qt6ct.conf`])
|
||||||
|
|
||||||
|
if( Config.general.color.wallust )
|
||||||
|
Wallust.generateColors(WallpaperPath.currentWallpaperPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyLightMode() {
|
||||||
|
if ( Config.general.color.schemeGeneration ) {
|
||||||
|
Quickshell.execDetached(["zshell-cli", "scheme", "generate", "--image-path", `${WallpaperPath.currentWallpaperPath}`, "--thumbnail-path", `${Paths.cache}/imagecache/thumbnail.jpg`, "--output", `${Paths.state}/scheme.json`, "--scheme", `${Config.colors.schemeType}`, "--mode", "light"]);
|
||||||
|
} else {
|
||||||
|
Quickshell.execDetached(["zshell-cli", "scheme", "generate", "--preset", `${DynamicColors.scheme}:${DynamicColors.flavour}`, "--output", `${Paths.state}/scheme.json`, "--mode", "light"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Config.general.color.mode = "light";
|
||||||
|
|
||||||
|
Quickshell.execDetached(["gsettings", "set", "org.gnome.desktop.interface", "color-scheme", "'prefer-light'"])
|
||||||
|
|
||||||
|
Quickshell.execDetached(["sh", "-c", `sed -i 's/color_scheme_path=\\(.*\\)Dark.colors/color_scheme_path=\\1Light.colors/' ${Paths.home}/.config/qt6ct/qt6ct.conf`])
|
||||||
|
|
||||||
|
if( Config.general.color.wallust )
|
||||||
|
Wallust.generateColors(WallpaperPath.currentWallpaperPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkStartup() {
|
||||||
|
if ( darkStart === darkEnd )
|
||||||
|
return;
|
||||||
|
var now = new Date();
|
||||||
|
if ( now.getHours() >= darkStart || now.getHours() < darkEnd ) {
|
||||||
|
applyDarkMode();
|
||||||
|
} else {
|
||||||
|
applyLightMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ Scope {
|
|||||||
property bool launcherInterrupted
|
property bool launcherInterrupted
|
||||||
readonly property bool hasFullscreen: Hypr.focusedWorkspace?.toplevels.values.some(t => t.lastIpcObject.fullscreen === 2) ?? false
|
readonly property bool hasFullscreen: Hypr.focusedWorkspace?.toplevels.values.some(t => t.lastIpcObject.fullscreen === 2) ?? false
|
||||||
|
|
||||||
|
|
||||||
CustomShortcut {
|
CustomShortcut {
|
||||||
name: "toggle-launcher"
|
name: "toggle-launcher"
|
||||||
description: "Toggle launcher"
|
description: "Toggle launcher"
|
||||||
|
|||||||
+4
-1
@@ -3,11 +3,14 @@ pragma Singleton
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
import qs.Config
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var args
|
property var args
|
||||||
|
readonly property string mode: Config.general.color.mode
|
||||||
|
readonly property string threshold: mode === "dark" ? "--threshold=9" : "--dynamic-threshold"
|
||||||
|
|
||||||
function generateColors(wallpaperPath) {
|
function generateColors(wallpaperPath) {
|
||||||
root.args = wallpaperPath;
|
root.args = wallpaperPath;
|
||||||
@@ -16,7 +19,7 @@ Singleton {
|
|||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: wallustProc
|
id: wallustProc
|
||||||
command: ["wallust", "run", root.args, "--palette=dark", "--ignore-sequence=cursor", "--threshold=9" ]
|
command: ["wallust", "run", root.args, `--palette=${root.mode}`, "--ignore-sequence=cursor", `${root.threshold}` ]
|
||||||
running: false
|
running: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user