Unverified Commit a1dc0a2f authored by vaw's avatar vaw Committed by GitHub

feat: Choose outputs by name (#602)

* feat: Choose outputs by name * Match the full monitor name + serial number like sway does * Updated documentation --------- Co-authored-by: 's avatarErik Reider <35975961+ErikReider@users.noreply.github.com>
parent 7765e0dd
...@@ -116,8 +116,10 @@ config file to be able to detect config errors ...@@ -116,8 +116,10 @@ config file to be able to detect config errors
type: string ++ type: string ++
default: "" ++ default: "" ++
description: The preferred output to open the notification window ++ description: The preferred output to open the notification window ++
(popup notifications). If the output is not found, the ++ (popup notifications). Can either be the monitor connector ++
currently focused one is picked. name (ex: "DP-1"), or the full name, manufacturer model serial ++
(ex: "Acer Technologies XV272U V 503023B314202"). ++
If the output is not found, the currently focused one is picked.
*keyboard-shortcuts* ++ *keyboard-shortcuts* ++
type: bool ++ type: bool ++
...@@ -183,7 +185,10 @@ config file to be able to detect config errors ...@@ -183,7 +185,10 @@ config file to be able to detect config errors
*control-center-preferred-output* ++ *control-center-preferred-output* ++
type: string ++ type: string ++
default: "" ++ default: "" ++
description: The preferred output to open the control center. If the ++ description: The preferred output to open the control center. Can either ++
be the monitor connector name (ex: "DP-1"), or ++
the full name, manufacturer model serial ++
(ex: "Acer Technologies XV272U V 503023B314202"). If the ++
output is not found, the currently focused one is picked. output is not found, the currently focused one is picked.
*notification-visibility* ++ *notification-visibility* ++
......
...@@ -472,6 +472,11 @@ namespace SwayNotificationCenter { ...@@ -472,6 +472,11 @@ namespace SwayNotificationCenter {
/** /**
* The preferred output to open the notification window (popup notifications). * The preferred output to open the notification window (popup notifications).
*
* Can either be the monitor connector name (ex: "DP-1"),
* or the full name, manufacturer model serial
* (ex: "Acer Technologies XV272U V 503023B314202").
*
* If the output is not found, the currently focused one is picked. * If the output is not found, the currently focused one is picked.
*/ */
public string notification_window_preferred_output { get; set; default = ""; } public string notification_window_preferred_output { get; set; default = ""; }
...@@ -618,6 +623,11 @@ namespace SwayNotificationCenter { ...@@ -618,6 +623,11 @@ namespace SwayNotificationCenter {
/** /**
* The preferred output to open the control center. * The preferred output to open the control center.
*
* Can either be the monitor connector name (ex: "DP-1"),
* or the full name, manufacturer model serial
* (ex: "Acer Technologies XV272U V 503023B314202").
*
* If the output is not found, the currently focused one is picked. * If the output is not found, the currently focused one is picked.
*/ */
public string control_center_preferred_output { get; set; default = ""; } public string control_center_preferred_output { get; set; default = ""; }
......
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
}, },
"notification-window-preferred-output": { "notification-window-preferred-output": {
"type": "string", "type": "string",
"description": "The preferred output to open the notification window (popup notifications). If the output is not found, the currently focused one is picked" "description": "The preferred output to open the notification window (popup notifications). Can either be the monitor connector name (ex: \"DP-1\"), or the full name, manufacturer model serial (ex: \"Acer Technologies XV272U V 503023B314202\"). If the output is not found, the currently focused one is picked"
}, },
"fit-to-screen": { "fit-to-screen": {
"type": "boolean", "type": "boolean",
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
}, },
"control-center-preferred-output": { "control-center-preferred-output": {
"type": "string", "type": "string",
"description": "The preferred output to open the control center. If the output is not found, the currently focused one is picked" "description": "The preferred output to open the control center. Can either be the monitor connector name (ex: \"DP-1\"), or the full name, manufacturer model serial (ex: \"Acer Technologies XV272U V 503023B314202\"). If the output is not found, the currently focused one is picked"
}, },
"keyboard-shortcuts": { "keyboard-shortcuts": {
"type": "boolean", "type": "boolean",
......
...@@ -369,9 +369,19 @@ namespace SwayNotificationCenter { ...@@ -369,9 +369,19 @@ namespace SwayNotificationCenter {
Object ? obj = monitors.get_item (i); Object ? obj = monitors.get_item (i);
if (obj == null || !(obj is Gdk.Monitor)) continue; if (obj == null || !(obj is Gdk.Monitor)) continue;
unowned Gdk.Monitor monitor = (Gdk.Monitor) obj; unowned Gdk.Monitor monitor = (Gdk.Monitor) obj;
if (monitor.connector == name) { if (monitor.connector == name) {
return monitor; return monitor;
} }
// Try matching a string consisting of the manufacturer + model + serial number.
// Just like Sway does (sway-output(5) man page)
string id = "%s %s %s".printf (monitor.manufacturer,
monitor.model,
monitor.description);
if (id == name) {
return monitor;
}
} }
return null; return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment