autorandr icon indicating copy to clipboard operation
autorandr copied to clipboard

Postswitch script fails to be executed

Open nicolamos opened this issue 3 years ago • 9 comments

I have an issue running a postswitch script with autorandr 1.11.

The script is located under '~/.config/autorandr/postswitch'. I tried just to echo something (the actual script just reapply the background that gets scrambled when switching profiles):

echo "POSTSWITCH"

When I manually issue autorandr

$ autorandr --force --debug my2monitor

I get the following error

Going to run:
xrandr --fb 2960x1050 --output DP-1 --crtc 1 --gamma 1.0:1.0:1.0 --mode 1280x1024 --pos 0x0 --rate 60.02 --reflect normal --rotate normal --output LVDS-1 --crtc 0 --gamma 1.0:1.0:1.0 --mode 1680x1050 --pos 1280x0 --primary --rate 59.88 --reflect normal --rotate normal
Failed to apply profile 'my2monitor' (line 1054):
  Failed to execute user command: /home/nicola/.config/autorandr/postswitch (line 1054)

This seems a duplicate of #152, but I think this can be a different issue.

nicolamos avatar Aug 25 '21 10:08 nicolamos

I'm running into the same issue, with the same line indicated in the postswitch -1054. My postswitch is basically the same as in #152 (Just moving workspaces in i3) , but the line number and symptoms match this issue. I can execute the postswitch manually, and everything works fine.

cculpepper avatar Sep 04 '21 21:09 cculpepper

Hey, try my fix :)

opalmay avatar Sep 30 '21 21:09 opalmay

Hey @opalmay Your fix worked great!

cculpepper avatar Oct 12 '21 02:10 cculpepper

@myrddin89 can you try adding

#! /bin/sh

in the first line of your script and make sure it's executable by running

chmod +x ~/.config/autorandr/postswitch

After that, your script should work without the suggested patch.

mephinet avatar Nov 04 '21 22:11 mephinet

@mephinet, That did not work. I reinstalled my distro's version (arch, 1.11.2), and postswitch still failed to execute. I had previously a shebang line of #!/bin/bash, but I also tried your #! /bin/sh, and my scripts have always been marked executable.

Changing the shebang did not fix the behavior, but reinstalling autorandr with @opalmay's fix worked and the postswitch executed correctly.

cculpepper avatar Nov 05 '21 14:11 cculpepper

Sorry for not responding for such a long time. Adding shell=True isn't the right solution. I suspect something is wrong with your script.

Does running ~/.config/autorandr/postswitch from the command line work as expected?

phillipberndt avatar Dec 16 '21 09:12 phillipberndt

:wave: Just commenting to say I had an issue with the postswitch script rarely running (arch/gnome/i3wm/[email protected]) and moving to 1.12 seems to have made everything happy

conner avatar Dec 18 '21 19:12 conner

Well I certainly have egg on my face, Turns out there was a space before my shebang that I didn't notice.

Funny thing was that running the script in the shell with ./ worked fine, which makes sense, it saw that line as a comment.

I don't know if that (Or autorandr 1.12) fixes @myrddin89 's issue, but mine can be chalked up to user error. Thank you for troubleshooting!

cculpepper avatar Dec 18 '21 21:12 cculpepper

Hey, kuddos to @mephinet, that fixed it for me

#! /bin/sh

in the first line of your script and make sure it's executable by running

chmod +x ~/.config/autorandr/postswitch

After that, your script should work without the suggested patch.

MartyLake avatar May 18 '22 11:05 MartyLake