-
Notifications
You must be signed in to change notification settings - Fork 127
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
Each script you are placing under valid configuration folders must follow **bash/sh/yourshell** format. As an example; | ||
|
||
```bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
#!/bin/bash | ||
notify-send -i display "Display profile" "$AUTORANDR_CURRENT_PROFILE" | ||
``` | ||
|
||
And script must hold **executable** rights. ex: `chmod +x your_script` | ||
|
||
#### Variables | ||
|
||
Some of autorandr's state is exposed as environment variables | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
raise AutorandrException("Failed to execute user command: %s" % (script,)) | ||
ran_scripts.add(script_name) | ||
|
||
|
@@ -1063,7 +1064,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) | ||
raise AutorandrException("Failed to execute user command: %s" % (script,)) | ||
ran_scripts.add(check_name) | ||
|
||
|
There was a problem hiding this comment.
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.)