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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.)


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.

#!/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
Expand Down
6 changes: 4 additions & 2 deletions autorandr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

raise AutorandrException("Failed to execute user command: %s" % (script,))
ran_scripts.add(script_name)

Expand All @@ -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)

Expand Down