Preswitch hook and arandr method for dumping current xrandr config #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
I wanted to use autorandr as I think it represents a brilliant idea. Unfortunately I had a problem with the dumper code, it seems to misinterpret the xrandr output. Here the output from xrandr:
Here's what autorandr outputs when --config option is used:
(Note the pos x for example).
When trying to load such config xrandr prints an error
Parsing xrandr seems very brave to me, since the command output can change from version to version (and I think this is what did happen and caused the isuse). Using the xrandr lib would be perfect, but then autorandr is such a shell script, right? Fortunately there's a nice Python utility to help called arandr that ships with a tool called unxrandr, that use the xrandr lib bindings to dump the current xrandr state in a form of a xrandr command call ready to use, for example:
I augmented the autorandr code to take advantage of this great tool. The patch follows the conventions already used by the tool author just adding a new method to dump the config (the idea of methods in the script is very nice!).
The second commit of the pull request is much more straight-forward. I added the preswitch hook that are launched just before the config is applied. This is useful for me, because I have an Intel card that is capable of displaying on at maximum 2 screen at once and can't switch from displaying 2 external screens to the laptop screen (the common scenario when detaching from a docking station) without disabling the external screens first. In this case I just put the following in the preswitch hook:
... and everything works nicely.
Hope this pull request makes sense to you and follows the conventions, thus could be merged for others' profit.