theotherjimmy / autorandr-rs

like autorandr, but kdl and a daemon
38 stars 4 forks source link

[Feature request] Pre/post switch hooks #6

Closed seqizz closed 3 years ago

seqizz commented 3 years ago

Just as something nice to have: It might be helpful to have some kind of command-triggering mechanism, configured in the toml file.

Since X is a mess with DPIs, I generally resize my terminal font etc via sed after the switch, but people generally need this for much more creative options.

theotherjimmy commented 3 years ago

How do you resize your terminal? Would this be better suited with reading the output of autorandrd(1) in a loop?

seqizz commented 3 years ago

I just trigger a sed to change font_size variable. Yet personally I am looking a better solution on DPI issues, instead of doing this.

Of course one can utilize output, or even use autorandrd with a wrapper, this was a suggestion to make the tool easier for migrators. People using the autorandr generally use this functionality to do some changes on their window manager (e.g. move a workspace) after a switch happens, so it would be helpful.

theotherjimmy commented 3 years ago

Yeah, I understand where that's coming from. I don't personally have a use for it though.

theotherjimmy commented 3 years ago

I've had a think about this, and I don't think autorandrd should do this. It seems: 1) out of place in the config file, as everything else is about displays here 2) easy to implement as part of a shell pipeline

In particular, it should be possible to write something in bash or awk to do what you want. Something like

#!/usr/bin/env bash
while read mon ; do "<your cmd>" ; done

or

#!/usr/bin/env awk
{ system("<your cmd> " $3) }

or something that matches on the name of the config:

#!/usr/bin/env awk
$3 == "<config1>" { system("<cmd-for-config1>") }
$3 == "<config2>" { system("<cmd-for-config2>") }

So I'm not planning on adding this feature.

seqizz commented 3 years ago

Fair enough.

Although I still see some value, so as a last question: How about adding a feature to query the currently active configuration to autorandrd, without triggering any changes? IMHO, these kind of shell pipes (inserted as a layer between the init system and binary) are just hacky. At least one can scriptize it on different targets if it's possible to query current state.

theotherjimmy commented 3 years ago

That seems like a good idea. Could you open another issue for that? I'll have a think on that in the mean time.