Skip to content

[draft] Add Setting to trigger command execution on monitor change - #8746

Closed
tcanabrava wants to merge 2 commits into
deskflow:masterfrom
tcanabrava:add_command_when_monitor_activates
Closed

[draft] Add Setting to trigger command execution on monitor change#8746
tcanabrava wants to merge 2 commits into
deskflow:masterfrom
tcanabrava:add_command_when_monitor_activates

Conversation

@tcanabrava

@tcanabrava tcanabrava commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

Rebased upon: #8919

@nbolton nbolton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code style: Please use camelCase instead of snake_case.

Comment thread src/lib/gui/config/IServerConfig.h Outdated
Comment thread src/lib/gui/config/Screen.cpp Outdated
@tcanabrava

tcanabrava commented Jul 9, 2025

Copy link
Copy Markdown
Contributor Author

@sithlord48 need your help here. I was unable to quickly find a way to read the settings of the Screens via a BaseClientProxy on Server.cpp
specially, the function I need to change is:

void Server::switchScreen(BaseClientProxy *dst, int32_t x, int32_t y, bool forScreensaver)

but aparently I do not have the possibility to read the config here.
and the code is quite confusing (there's a Config.h, that the server uses, there's also a ServerConfig.h that the server does't uses? wtf?)

@nbolton - your help here is appreciated too.

@nbolton

nbolton commented Jul 9, 2025

Copy link
Copy Markdown
Member

read the settings of the Screens via a BaseClientProxy on Server.cpp

So from within the Core (server/client) you want to read server-specific settings? Try src/lib/server/Config.h:
https://github.com/deskflow/deskflow/blob/f12f312dab75ec97b028ed80a3c0bda2178f1d19/src/lib/server/Config.h

It may be helpful for you to know that the server settings in the Core are loaded in src/lib/deskflow/ServerApp.cpp:

configStream >> *args().m_config;

and the code is quite confusing (there's a Config.h, that the server uses, there's also a ServerConfig.h that the server does't uses? wtf?)

It's because the [newer] GUI is modelled on the [ancient] Core; the concept of configuring the server came first, which is why it has it's own config. For a long time the only way to configure the client was through CLI (and part of the server config was done via CLI too) -- edit: and technically this is still the case; the as the GUI sends the Core CLI args. The Config class in the GUI is to configure "everything except for the 'server' config" such as settings common between the server and client as well as GUI settings.

I believe Chris R's vision is to replace this bifurcated config mess with a single unified config. edit: and we would drop the notion of configuring the Core via CLI; it would be done by reading the Qt config directly from within the Core.

@nbolton

nbolton commented Jul 9, 2025

Copy link
Copy Markdown
Member

[draft]

If this is still a draft, shall we switch the PR to draft mode to make it clearer?

@tcanabrava

Copy link
Copy Markdown
Contributor Author

[draft]

If this is still a draft, shall we switch the PR to draft mode to make it clearer?

I assumed it would automatically pick up as draft as soon as I added the [draft] on the title. it used to do that.
My goal here is to be able to automatically switch the monitor hdmi cable based on the screen my mouse moves to (since I have a single monitor).
This can't be done automatically for everyone, obviously, so adding a "enter command" and "leave command" seemed the correct thing to do.

@tcanabrava

Copy link
Copy Markdown
Contributor Author

read the settings of the Screens via a BaseClientProxy on Server.cpp

So from within the Core (server/client) you want to read server-specific settings? Try src/lib/server/Config.h: https://github.com/deskflow/deskflow/blob/f12f312dab75ec97b028ed80a3c0bda2178f1d19/src/lib/server/Config.h

It may be helpful for you to know that the server settings in the Core are loaded in src/lib/deskflow/ServerApp.cpp:

configStream >> *args().m_config;

No, I want to be able to read the gui/config/Screen.h settings - I added two new ones there for each connected screen.

@tcanabrava

Copy link
Copy Markdown
Contributor Author

@nbolton tried to change to draft mode but I don't seem to be able to access the draft checkbox.

@sithlord48
sithlord48 marked this pull request as draft July 9, 2025 12:30
@sithlord48

sithlord48 commented Jul 9, 2025

Copy link
Copy Markdown
Member

@tcanabrava i added draft for you. I think some of this you can split out and we can land as just general improvements iirc the first 3 commits.

you need to set the option in the gui setting's internalConfiguration section then it can be used to generate server settings. The server and screen settings need to be updated they are confusion for sure.

Also when this is ready we use tags like refactor: , feat , fix etc on our commits check the style guide on the wiki. It helps alot when it comes to auto gen release notes.

@sithlord48

This comment was marked as outdated.

@tcanabrava

Copy link
Copy Markdown
Contributor Author

sorry about the dialog thing. we can minimize it to the minimum size without issues. my desktop screen is quite large and I have not realized it.

Comment thread src/lib/gui/config/Screen.cpp Outdated

auto enter_command = settings.value("EnterScreenCommand").toString();
m_enterScreenCommand = enter_command.isEmpty()? std::nullopt : enter_command;
if (enter_command.isEmpty()) {

@sithlord48 sithlord48 Jul 29, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if we do this as a general rule when replacing ternary operations.

m_var = std::nullopt;
if (!foo.isEmpty())
  m_var = otherValue;

It will take a moment in execution but maybe ultimately safer. What do u think Tomaz ?

@sithlord48
sithlord48 force-pushed the add_command_when_monitor_activates branch 3 times, most recently from 70bdd9a to 3bedb70 Compare September 3, 2025 11:26
@sithlord48
sithlord48 force-pushed the add_command_when_monitor_activates branch from 3bedb70 to 7543c2d Compare September 10, 2025 17:34
@sithlord48 sithlord48 mentioned this pull request Nov 1, 2025
5 tasks
@sithlord48
sithlord48 force-pushed the add_command_when_monitor_activates branch from 7543c2d to 623acd5 Compare December 30, 2025 22:15
@sithlord48 sithlord48 added the 🪄 feature request This PR adds a requested feature label Jan 17, 2026
@sithlord48
sithlord48 force-pushed the add_command_when_monitor_activates branch from 623acd5 to 2543248 Compare March 11, 2026 01:16
@sithlord48

sithlord48 commented Mar 12, 2026

Copy link
Copy Markdown
Member

@tcanabrava / @nbolton I have been thinking about this and I am not sure that we need to set this on the server side.

Since the main use case for this feature will be to send commands to the monitor to switch inputs the setting should be done in the generic settings this would make the entry / exit command the same no matter what mode is being used (and no matter what server your connected to when a client). It would also be easier to implement.

@sithlord48

Copy link
Copy Markdown
Member

replaced by #9564

@sithlord48 sithlord48 closed this Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🪄 feature request This PR adds a requested feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants