mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-28 23:42:51 -05:00
@@ -4,6 +4,7 @@ import QtQuick.Controls
|
|||||||
import QtQuick.Effects
|
import QtQuick.Effects
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Hyprland
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import Quickshell.Services.Greetd
|
import Quickshell.Services.Greetd
|
||||||
import Quickshell.Services.Pam
|
import Quickshell.Services.Pam
|
||||||
@@ -35,19 +36,40 @@ Item {
|
|||||||
randomFact = Facts.getRandomFact()
|
randomFact = Facts.getRandomFact()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property bool weatherInitialized: false
|
||||||
|
|
||||||
|
function initWeatherService() {
|
||||||
|
if (weatherInitialized)
|
||||||
|
return
|
||||||
|
if (!GreetdSettings.settingsLoaded)
|
||||||
|
return
|
||||||
|
if (!GreetdSettings.weatherEnabled)
|
||||||
|
return
|
||||||
|
|
||||||
|
weatherInitialized = true
|
||||||
|
WeatherService.addRef()
|
||||||
|
WeatherService.forceRefresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: GreetdSettings
|
||||||
|
function onSettingsLoadedChanged() {
|
||||||
|
if (GreetdSettings.settingsLoaded)
|
||||||
|
initWeatherService()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
pickRandomFact()
|
pickRandomFact()
|
||||||
WeatherService.addRef()
|
initWeatherService()
|
||||||
|
|
||||||
if (isPrimaryScreen) {
|
if (isPrimaryScreen) {
|
||||||
sessionListProc.running = true
|
sessionListProc.running = true
|
||||||
applyLastSuccessfulUser()
|
applyLastSuccessfulUser()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CompositorService.isHyprland) {
|
if (CompositorService.isHyprland)
|
||||||
updateHyprlandLayout()
|
updateHyprlandLayout()
|
||||||
hyprlandLayoutUpdateTimer.start()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyLastSuccessfulUser() {
|
function applyLastSuccessfulUser() {
|
||||||
@@ -61,10 +83,8 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
WeatherService.removeRef()
|
if (weatherInitialized)
|
||||||
if (CompositorService.isHyprland) {
|
WeatherService.removeRef()
|
||||||
hyprlandLayoutUpdateTimer.stop()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateHyprlandLayout() {
|
function updateHyprlandLayout() {
|
||||||
@@ -106,14 +126,15 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Connections {
|
||||||
id: hyprlandLayoutUpdateTimer
|
target: CompositorService.isHyprland ? Hyprland : null
|
||||||
interval: 1000
|
enabled: CompositorService.isHyprland
|
||||||
running: false
|
|
||||||
repeat: true
|
|
||||||
onTriggered: updateHyprlandLayout()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
function onRawEvent(event) {
|
||||||
|
if (event.name === "activelayout")
|
||||||
|
updateHyprlandLayout()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: GreetdMemory
|
target: GreetdMemory
|
||||||
@@ -750,13 +771,13 @@ Item {
|
|||||||
visible: {
|
visible: {
|
||||||
const keyboardVisible = (CompositorService.isNiri && NiriService.keyboardLayoutNames.length > 1) ||
|
const keyboardVisible = (CompositorService.isNiri && NiriService.keyboardLayoutNames.length > 1) ||
|
||||||
(CompositorService.isHyprland && hyprlandLayoutCount > 1)
|
(CompositorService.isHyprland && hyprlandLayoutCount > 1)
|
||||||
return keyboardVisible && WeatherService.weather.available
|
return keyboardVisible && GreetdSettings.weatherEnabled && WeatherService.weather.available
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
spacing: 6
|
spacing: 6
|
||||||
visible: WeatherService.weather.available
|
visible: GreetdSettings.weatherEnabled && WeatherService.weather.available
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
@@ -780,7 +801,7 @@ Item {
|
|||||||
height: 24
|
height: 24
|
||||||
color: Qt.rgba(255, 255, 255, 0.2)
|
color: Qt.rgba(255, 255, 255, 0.2)
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
visible: WeatherService.weather.available && (NetworkService.networkStatus !== "disconnected" || BluetoothService.enabled || (AudioService.sink && AudioService.sink.audio) || BatteryService.batteryAvailable)
|
visible: GreetdSettings.weatherEnabled && WeatherService.weather.available && (NetworkService.networkStatus !== "disconnected" || BluetoothService.enabled || (AudioService.sink && AudioService.sink.audio) || BatteryService.batteryAvailable)
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import QtQuick
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import qs.Common
|
import qs.Common
|
||||||
|
import qs.Modules.Greetd
|
||||||
import "../Common/suncalc.js" as SunCalc
|
import "../Common/suncalc.js" as SunCalc
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
@@ -509,27 +510,29 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateLocation() {
|
function updateLocation() {
|
||||||
if (SettingsData.useAutoLocation) {
|
const useAuto = SessionData.isGreeterMode ? GreetdSettings.useAutoLocation : SettingsData.useAutoLocation;
|
||||||
|
const coords = SessionData.isGreeterMode ? GreetdSettings.weatherCoordinates : SettingsData.weatherCoordinates;
|
||||||
|
const cityName = SessionData.isGreeterMode ? GreetdSettings.weatherLocation : SettingsData.weatherLocation;
|
||||||
|
|
||||||
|
if (useAuto) {
|
||||||
getLocationFromIP();
|
getLocationFromIP();
|
||||||
} else {
|
return;
|
||||||
const coords = SettingsData.weatherCoordinates;
|
}
|
||||||
if (coords) {
|
|
||||||
const parts = coords.split(",");
|
if (coords) {
|
||||||
if (parts.length === 2) {
|
const parts = coords.split(",");
|
||||||
const lat = parseFloat(parts[0]);
|
if (parts.length === 2) {
|
||||||
const lon = parseFloat(parts[1]);
|
const lat = parseFloat(parts[0]);
|
||||||
if (!isNaN(lat) && !isNaN(lon)) {
|
const lon = parseFloat(parts[1]);
|
||||||
getLocationFromCoords(lat, lon);
|
if (!isNaN(lat) && !isNaN(lon)) {
|
||||||
return;
|
getLocationFromCoords(lat, lon);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cityName = SettingsData.weatherLocation;
|
|
||||||
if (cityName) {
|
|
||||||
getLocationFromCity(cityName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cityName)
|
||||||
|
getLocationFromCity(cityName);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLocationFromCoords(lat, lon) {
|
function getLocationFromCoords(lat, lon) {
|
||||||
@@ -867,7 +870,7 @@ Singleton {
|
|||||||
Timer {
|
Timer {
|
||||||
id: updateTimer
|
id: updateTimer
|
||||||
interval: nextInterval()
|
interval: nextInterval()
|
||||||
running: root.refCount > 0 && SettingsData.weatherEnabled
|
running: root.refCount > 0 && SettingsData.weatherEnabled && !SessionData.isGreeterMode
|
||||||
repeat: true
|
repeat: true
|
||||||
triggeredOnStart: true
|
triggeredOnStart: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
|
|||||||
Reference in New Issue
Block a user