forked from Shinonome/dots-hyprland
brightness controller: per-name config; add "auto"
This commit is contained in:
@@ -39,7 +39,14 @@ let configOptions = {
|
|||||||
'warnMessages': ["Plug in the charger", "You there?", 'PLUG THE CHARGER ALREADY'],
|
'warnMessages': ["Plug in the charger", "You there?", 'PLUG THE CHARGER ALREADY'],
|
||||||
},
|
},
|
||||||
'brightness': {
|
'brightness': {
|
||||||
'controller': "brightnessctl", // "brightnessctl" or "ddcutil"
|
// Object of controller names for each monitor, either "brightnessctl" or "ddcutil" or "auto"
|
||||||
|
// "default" will be used if unspecified
|
||||||
|
// Examples
|
||||||
|
// 'eDP-1': "brightnessctl",
|
||||||
|
// 'DP-1': "ddcutil",
|
||||||
|
'controllers': {
|
||||||
|
'default': "auto",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'music': {
|
'music': {
|
||||||
'preferredPlayer': "plasma-browser-integration",
|
'preferredPlayer': "plasma-browser-integration",
|
||||||
|
|||||||
@@ -89,20 +89,33 @@ class BrightnessDdcService extends BrightnessServiceBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// the singleton instance
|
// Service instance
|
||||||
const numMonitors = Hyprland.monitors.length;
|
const numMonitors = Hyprland.monitors.length;
|
||||||
const service = Array(numMonitors);
|
const service = Array(numMonitors);
|
||||||
switch (userOptions.brightness.controller) {
|
for (let i = 0; i < service.length; i++) {
|
||||||
case "brightnessctl":
|
const monitorName = Hyprland.monitors[i].name;
|
||||||
service.fill(new BrightnessCtlService());
|
const preferredController = userOptions.brightness.controllers[monitorName]
|
||||||
break;
|
|| userOptions.brightness.controllers.default || "auto";
|
||||||
case "ddcutil":
|
if (preferredController) {
|
||||||
for (let i = 0; i < numMonitors; i++) {
|
switch (preferredController) {
|
||||||
service[i] = new BrightnessDdcService(i);
|
case "brightnessctl":
|
||||||
|
service[i] = new BrightnessCtlService();
|
||||||
|
break;
|
||||||
|
case "ddcutil":
|
||||||
|
service[i] = new BrightnessDdcService(i);
|
||||||
|
break;
|
||||||
|
case "auto":
|
||||||
|
if (monitorName.startsWith("eDP-"))
|
||||||
|
service[i] = new BrightnessCtlService();
|
||||||
|
else if (monitorName.startsWith("DP-"))
|
||||||
|
service[i] = new BrightnessDdcService(i);
|
||||||
|
else
|
||||||
|
service[i] = new BrightnessCtlService();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown brightness controller ${preferredController}`);
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
default:
|
|
||||||
throw new Error(`Unknown brightness controller ${userOptions.brightness.controller}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// make it global for easy use with cli
|
// make it global for easy use with cli
|
||||||
|
|||||||
Reference in New Issue
Block a user