Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a toggle for adaptive_sync #7817

Closed
wants to merge 0 commits into from

Conversation

Emil-Engberg
Copy link
Contributor

When i don't play a game i don't want adaptive_sync enabled.(Because the backlight flickers when screen updates). But it was quite inconvenient to go into the sway config to enable and disable it every time. So i added a toggle option to adaptive_sync. For example in my config:
bindsym $mod+p output DP-3 adaptive_sync toggle makes it so that every time i press $mod + p the adaptive_sync for DP-3 gets toggled on or off.

@emersion
Copy link
Member

parse_boolean already supports "toggle". It just needs to be fed the current value.

@GrabbenD
Copy link

Here's my current approach to automatically toggling VRR: #5076 (comment)

@Emil-Engberg
Copy link
Contributor Author

@GrabbenD Yes that is a solution. Sadly the display flicker is still visible when in full screen. Most of the time that don't matter but i sometimes like to have my browser window and other apps fullscreen. I know you can create a toggle with a bash script but when i saw that other options that was on or off had a toggle. I thought that it would be more convenient to just add a toggle to adaptive_sync. I don't need adaptive sync so often that i need it to be enabled automatically. But maybe that just me?

@emersion
Copy link
Member

sway/commands/output/power.c can be used as inspiration.

@emersion
Copy link
Member

Can't apply this patch to this PR, getting permission denied:

From b0469289916c076528ddf4ce7a3cc52f1907fca7 Mon Sep 17 00:00:00 2001
From: Simon Ser <contact@emersion.fr>
Date: Tue, 19 Dec 2023 19:31:17 +0100
Subject: [PATCH] Use strcasecmp, error out on '*'

---
 sway/commands/output/adaptive_sync.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/sway/commands/output/adaptive_sync.c b/sway/commands/output/adaptive_sync.c
index 54db69db7591..610133b6f88c 100644
--- a/sway/commands/output/adaptive_sync.c
+++ b/sway/commands/output/adaptive_sync.c
@@ -1,3 +1,4 @@
+#include <strings.h>
 #include "sway/commands.h"
 #include "sway/config.h"
 #include "sway/output.h"
@@ -13,14 +14,19 @@ struct cmd_results *output_cmd_adaptive_sync(int argc, char **argv) {
 
 	bool current_value = true;
 	
-	if (strcmp(argv[0], "toggle") == 0) {
-		struct output_config *oc = config->handler_context.output_config;
-		struct sway_output *sway_output = all_output_by_name_or_id(oc->name);
+	if (strcasecmp(argv[0], "toggle") == 0) {
+		const char *oc_name = config->handler_context.output_config->name;
+		if (strcmp(oc_name, "*") == 0) {
+			return cmd_results_new(CMD_INVALID,
+				"Cannot apply toggle to all outputs");
+		}
 
+		struct sway_output *sway_output = all_output_by_name_or_id(oc_name);
 		if (!sway_output || !sway_output->wlr_output) {
 			return cmd_results_new(CMD_FAILURE,
-				   "Cannot apply toggle to unknown output %s", oc->name);
+				"Cannot apply toggle to unknown output %s", oc_name);
 		}
+
 		current_value =
 			sway_output->wlr_output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED;
 	}
@@ -30,4 +36,4 @@ struct cmd_results *output_cmd_adaptive_sync(int argc, char **argv) {
 	config->handler_context.leftovers.argc = argc - 1;
 	config->handler_context.leftovers.argv = argv + 1;
 	return NULL;
-}
\ No newline at end of file
+}
-- 
2.43.0

@emersion
Copy link
Member

Any chance you'd have some time to update this PR?

Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@emersion
Copy link
Member

emersion commented Mar 9, 2024

Hm, can't merge: "This branch cannot be rebased due to conflicts"

Please rebase against master.

@emersion
Copy link
Member

This wasn't a rebase, this was a merge commit. Tried to fix it up manually but somehow GitHub got mad. Manually merged in e940acd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants