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

Valid post/pre script format #265

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

yaman
Copy link

@yaman yaman commented Oct 9, 2021

This pr includes 2 commits;

  1. Information about valid script format and file permissions to be executed properly by autorandr at Readme.md
  2. Simple tracing by printing subprocess exceptions at catch block to analyse call() function fails with reasons.

Readme is updated with missing script format: a file with shebang chars and executable permissions
Subprocess exception handling is updated to print more information for the failed process call() reasons. This was particularly very useful when debugging why post/pre scripts are not executed properly.
Copy link
Owner

@phillipberndt phillipberndt left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution. Left a few comments.

@@ -199,6 +199,17 @@ a new monitor, then you can use a `predetect` script to delay the execution.
Write e.g. `sleep 1` into that file to make autorandr wait a second before
running `xrandr`.

### Script format
Copy link
Owner

Choose a reason for hiding this comment

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

Actually all that's needed is that the files are executable. They don't have to be shell scripts. (They don't even have to be scripts. A binary would work as well.)

@@ -1050,7 +1050,8 @@ def exec_scripts(profile_path, script_name, meta_information=None):
if os.access(script, os.X_OK | os.F_OK):
try:
all_ok &= subprocess.call(script, env=env) != 0
except:
except Exception as process_exception:
print(process_exception):
Copy link
Owner

Choose a reason for hiding this comment

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

This looks like a syntax error.

Besides, what's the idea behind this print? Perhaps the same can be done more elegantly.


Each script you are placing under valid configuration folders must follow **bash/sh/yourshell** format. As an example;

```bash
Copy link
Owner

Choose a reason for hiding this comment

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

I like the idea of having a few examples. How about creating a folder under contrib and collecting all sorts of scripts there? We could then link to that folder from here.

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

Successfully merging this pull request may close these issues.

2 participants