Merge branch 'main' of github.com:noctalia-dev/noctalia-shell
This commit is contained in:
commit
bb1d56121d
4 changed files with 123 additions and 37 deletions
|
|
@ -3,6 +3,7 @@ pragma Singleton
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Bluetooth
|
||||
import qs.Commons
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
|
@ -85,8 +86,23 @@ Singleton {
|
|||
function canConnect(device) {
|
||||
if (!device)
|
||||
return false
|
||||
/*
|
||||
Paired
|
||||
|
||||
return !device.paired && !device.pairing && !device.blocked
|
||||
Means you’ve successfully exchanged keys with the device.
|
||||
|
||||
The devices remember each other and can authenticate without repeating the pairing process.
|
||||
|
||||
Example: once your headphones are paired, you don’t need to type a PIN every time.
|
||||
Hence, instead of !device.paired, should be device.connected
|
||||
*/
|
||||
return !device.connected && !device.pairing && !device.blocked
|
||||
}
|
||||
|
||||
function canDisconnect(device) {
|
||||
if (!device)
|
||||
return false
|
||||
return device.connected && !device.pairing && !device.blocked
|
||||
}
|
||||
|
||||
function getSignalStrength(device) {
|
||||
|
|
@ -162,7 +178,6 @@ Singleton {
|
|||
return
|
||||
}
|
||||
|
||||
device.trusted = false
|
||||
device.disconnect()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ Singleton {
|
|||
property list<var> ddcMonitors: []
|
||||
readonly property list<Monitor> monitors: variants.instances
|
||||
property bool appleDisplayPresent: false
|
||||
|
||||
|
||||
function getMonitorForScreen(screen: ShellScreen): var {
|
||||
return monitors.find(m => m.modelData === screen)
|
||||
}
|
||||
|
|
@ -69,19 +69,35 @@ Singleton {
|
|||
// Detect DDC monitors
|
||||
Process {
|
||||
id: ddcProc
|
||||
command: ["ddcutil", "detect", "--brief"]
|
||||
property list<var> ddcMonitors: []
|
||||
command: ["ddcutil", "detect", "--sleep-multiplier=0.5"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
// Do not filter out invalid displays. For some reason --brief returns some invalid which works fine
|
||||
var displays = text.trim().split("\n\n")
|
||||
root.ddcMonitors = displays.map(d => {
|
||||
var modelMatch = d.match(/Monitor:.*:(.*):.*/)
|
||||
|
||||
|
||||
ddcProc.ddcMonitors = displays.map(d => {
|
||||
|
||||
var ddcModelMatc = d.match(/This monitor does not support DDC\/CI/)
|
||||
var modelMatch = d.match(/Model:\s*(.*)/)
|
||||
var busMatch = d.match(/I2C bus:[ ]*\/dev\/i2c-([0-9]+)/)
|
||||
var ddcModel = ddcModelMatc ? ddcModelMatc.length > 0 : false
|
||||
var model = modelMatch ? modelMatch[1] : "Unknown"
|
||||
var bus = busMatch ? busMatch[1] : "Unknown"
|
||||
Logger.log(
|
||||
"Detected DDC Monitor:", model,
|
||||
"on bus", bus, "is DDC:", !ddcModel
|
||||
)
|
||||
return {
|
||||
"model": modelMatch ? modelMatch[1] : "",
|
||||
"busNum": busMatch ? busMatch[1] : ""
|
||||
"model": model,
|
||||
"busNum": bus,
|
||||
"isDdc": !ddcModel,
|
||||
}
|
||||
})
|
||||
root.ddcMonitors = ddcProc.ddcMonitors.filter(m => m.isDdc)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue