You are not logged in.

#1 2016-08-16 02:39:25

GodlikeHobbit
Member
From: Queensland, Australia
Registered: 2016-08-16
Posts: 4

[SOLVED] Unable to get feh to run from udev rule

Hey guys, I recently decided to write a script that would change my lock icon and wallpaper depending on the keyboard I have plugged in (only 3 for the laptop so far), i wrote a set of udev rules to get the script to run when the keyboard is plugged in/removed, the rule triggers and the script does get run but feh doesnt change my wallpaper, I've looked around for an answer and tried a bunch of things, none of which worked, I was hoping one of you had already figured it out.


The script does run, anything commented out is something I already tried in order to get it to work.
Everything works the way I intended except for the feh command(s).

#!/bin/bash
#sleep 5
#export DISPLAY=:0
COLOR="Purple"
DIRECTORY="/home/godlikehobbit/Desktop/WallpaperFiles/"
if lsusb | grep -q "04d9:0141"; then
    # Pok3r
    COLOR="Pink"
else
	if lsusb | grep -q "2516:0027"; then
    	# Novatouch
    	COLOR="Rainbow"
    else
    	# ScissorSwitch
    	COLOR="Purple"
    fi
fi
# Set background and lock.png
killall feh
feh --bg-scale "$DIRECTORY""$COLOR"Miami.png
#other attempts
#DISPLAY=:0 feh --bg-scale /home/godlikehobbit/Desktop/WallpaperFiles/PurpleMiami.png
#echo -e "#!/bin/bash\nfeh --bg-scale /home/godlikehobbit/Desktop/WallpaperFiles/PurpleMiami.png" > /home/godlikehobbit/.test
#exec /home/godlikehobbit/.test
#su -c "feh --bg-scale /home/godlikehobbit/Desktop/WallpaperFiles/PurpleMiami.png" godlikehobbit
cp "$DIRECTORY""$COLOR"Lock.png /usr/share/i3lock-fancy/lock.png;

Last edited by GodlikeHobbit (2016-08-16 17:00:46)

Offline

#2 2016-08-16 03:10:12

frank604
Member
From: BC, Canada
Registered: 2011-04-20
Posts: 1,219

Re: [SOLVED] Unable to get feh to run from udev rule

Does background change when you do:

feh --bg-scale /home/godlikehobbit/Desktop/WallpaperFiles/PinkMiami.png &

Last edited by frank604 (2016-08-16 03:10:23)

Offline

#3 2016-08-16 06:01:02

GodlikeHobbit
Member
From: Queensland, Australia
Registered: 2016-08-16
Posts: 4

Re: [SOLVED] Unable to get feh to run from udev rule

Still doesn't change at all, script is definitely still executing because the lock icon is changing

Offline

#4 2016-08-16 09:06:45

bullet
Member
Registered: 2016-08-04
Posts: 18

Re: [SOLVED] Unable to get feh to run from udev rule

Well then your WM/desktop environment is handling stuff a bit differently.

For example I'm using XFCE at the moment and using feh does not set the background either. XFCE does not seem to show the root window so obviously setting a bg for it doesn't work. Go check what your WM/DE's standard way of changing the bg is then use that.

Offline

#5 2016-08-16 16:58:38

GodlikeHobbit
Member
From: Queensland, Australia
Registered: 2016-08-16
Posts: 4

Re: [SOLVED] Unable to get feh to run from udev rule

I resorted to changing the script that sets my wallpaper when my windows manager starts and restarting it whenever I plug in a keyboard using:

pkill -SIGHUP awesome

However now I've run into an entirely different issue in that sometimes when I plug in a keyboard X crashes with a variety of different error messages, from segmentation faults to firefox fatal IO error 11, maybe someone else can try executing a script from a udev rule that restarts awesomewm, for now though it looks like its bugged. Thanks for the help guys.

Offline

#6 2016-08-16 17:21:20

frank604
Member
From: BC, Canada
Registered: 2011-04-20
Posts: 1,219

Re: [SOLVED] Unable to get feh to run from udev rule

GodlikeHobbit wrote:

Still doesn't change at all, script is definitely still executing because the lock icon is changing

Then that means the fault doesn't lie in your script but rather in what controls your background and/or feh not working as intended.  In the future just simplify your troubleshooting and test your action line in the script by itself.  In this case it was the line to execute feh.  Not sure how you solved this as it doesn't seem solved but good luck!

Offline

#7 2016-08-18 02:52:36

GodlikeHobbit
Member
From: Queensland, Australia
Registered: 2016-08-16
Posts: 4

Re: [SOLVED] Unable to get feh to run from udev rule

This might help someone some day, I was tinkering with the script again and tried running the script directly as my user with su:

su -c "/home/godlikehobbit/Desktop/WallpaperFiles/swapColors2.sh" godlikehobbit

swapColors2.sh contains the original feh command etc.
For some reason when udev rules run a script as a specific user a lot of things that should work don't, running a separate script using su seems to be a workaround, no crashes as of yet.

Offline

Board footer

Powered by FluxBB