Skip to content
New issue

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

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

Already on GitHub? # to your account

Feature: virtual desktop sensor and command #12

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

amadeo-alex
Copy link

@amadeo-alex amadeo-alex commented Jul 3, 2023

This PR adds sensor and command requested via LAB02-Research/HASS.Agent#263 .

Due to how "nicely" microsoft is handling virtual desktops the best way to go was with library dedicated for this purpose (end even this can break when windows updates). I've decided to go with https://github.com/Grabacr07/VirtualDesktop for the following reasons:

  • widest list of supported systems
  • mature design
  • dynamic COM assembly checks/building

This library offers more functionality that what has been added in this PR and due to this, requires initialisation (at least first call) from UI/STA thread.
The library itself doesn't provide virtual desktop names for Windows 10, in this case they are retrieved from registry (only if the virtual desktop has been renamed to something custom by the user)

PR itself adds/changes following things:

  • "ActiveDesktop" sensor - provides ID of currently active virtual desktop (including name if exists) as well as json list of all available desktops (ID + optionally name if exists)
  • "SwitchDesktop" action command - allows to switch to provided virtual desktop
  • Bumps projects target/supported version (see below)

@LAB02-Admin
I've bumped the project target/supported versions because the feature set of HASS.Agent it wouldn't allow it to be fully functional on anything below Windows 10. Please ping me if you'd like me to revert this :)

Tested on Windows 10 10.0.19042.

obraz

Example command to switch the virtual desktop:

service: mqtt.publish
data:
  topic: homeassistant/button/AMADEO-PC/AMADEO-PC_switchdesktop/action
  payload: a81a8943-c969-4659-94f2-3c63a4a45924

@amadeo-alex amadeo-alex marked this pull request as ready for review July 3, 2023 16:00
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant