Jump to content

Want to run my shell script at X startup


Recommended Posts

I use fluxbox as my window manager and have written a script called autostart.sh which gets run when fluxbox is started.

 

I tried to use a package that was supposed to randomly set my background based on images in a given directory - this didn't work so I wrote a simple Java class to do the same.

 

I then wrote a simple shell script to run it and added this to autostart.sh as something to run when fluxbox is started.

 

Nothing happens. If, however, I run my script in a konsole - all works beautifully. What's going on here?

 

My script is as follows

 

export CLASSPATH=$CLASSPATH:~/.fluxbox

java BackgroundChanger ~/.fluxbox/backgrounds

Link to comment
Share on other sites

I don't know anything about java, but if you want a simple shell script to randomly display an image in the fluxbox background, here you are:

 

#! /bin/bash

# wallpaperRandom



wallpaper_cmd="/usr/X11R6/bin/wmsetbg -s "

images_dir="${HOME}/xresources/backgrounds/"

images_filter="*.jpg"



images_list=($(/bin/ls ${images_dir}/${images_filter}))

image=${images_list[$((${RANDOM}%${#images_list[@]}))]}



exec ${wallpaper_cmd} ${image} &

 

The code is extracted from a dedicated function coded in my own fluxboxrc (the equivalent to your autostart.sh); If you are interested I can post it here. To use the 'wallpaperRandom' script just make it executable and call it from your autostart.sh

 

HTH

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...