set wallpaper
 
      
       Forum: DSL Tips and Tricks 
    Topic: set wallpaper 
 started by: humpty
     
    Posted by humpty on Dec. 01 2007,16:48  
        It seems xrsi doesn't mind if the wallpaper doesn't have an extension. This means it's fairly easy to manage your wallpaper.
  ----------------- Create this file which will set the new default wallpaper and load it; 	/home/dsl/.dfmdesk/wallpaper/set_wallpaper
 | Quote  |  #!/bin/bash 		cp $1 /home/dsl/.dfmdesk/wallpaper/default 		xsri --scale-width=100 --scale-height=100 /home/dsl/.dfmdesk/wallpaper/default
  |  
  In /home/dsl/.fluxbox.inc (or whatever window manager .inc file) add this line at the bottom to load the wallpaper at startup;
 | Quote  |  xsri --scale-width=100 --scale-height=100 home/dsl/.dfmdesk/wallpaper/default
  |  
  You can now drag/drop pictures into the set_wallpaper script in your desktop wallpaper folder to load and set the default wallpaper.
  In dfm, the wallpaper might disappear if you press 'esc' on a blank desktop or 'update' on an icon. You can create an additional script to reload it;  	/home/dsl/.dfmdesk/wallpaper/reload_wallpaper;
 | Quote  |  #!/bin/bash 		pkill dfm && dfm 		sleep 1 		xsri --scale-width=100 --scale-height=100 /home/dsl/.dfmdesk/wallpaper/default
  |  
  ----------------- If you use emelfm, you can also add this user-command e.g "set wallpaper"
 | Quote  |  cp %f /home/dsl/.dfmdesk/wallpaper/default
  |  
 
  -----------------
   
    Posted by mikshaw on Dec. 01 2007,20:25  
        I wonder why you need to copy the file? This single line should do as well as the two you have: xsri --scale-width=100 --scale-height=100 $1
  In any case, that's a handy tip. thanks
   
    Posted by humpty on Dec. 01 2007,22:21  
        | Quote (mikshaw @ Dec. 01 2007,23:25) |  | I wonder why you need to copy the file? |  
  the file might be from a temporary source, (and the name needs to be the same for reloading at reboot).
   
    Posted by mikshaw on Dec. 02 2007,03:32  
        That makes sense.
  In situations that reuse the same file, though, I've found that using an environment variable for that file can be very useful. In that way you can prevent the need to edit all scripts that use that file if you happen to change the file path (using the scripts on a system without dfm, for example), and at the same time probably cut the size of your scripts by several bytes.
   
    Posted by roberts on Dec. 02 2007,05:56  
        So using this scheme every window manager has the same wallpaper?
   
    Posted by jpeters on Dec. 02 2007,16:45  
        | Quote (mikshaw @ Dec. 01 2007,15:25) |  I wonder why you need to copy the file? This single line should do as well as the two you have: xsri --scale-width=100 --scale-height=100 $1
  In any case, that's a handy tip. thanks |  
  I believe the --scale-width=100 --scale-height=100 options are assigned by default.
  Edit: after trying it, it seems you need it!
  BTW/ very cool! Thanks   (now here's an excellent use for icons /drag & drop...(put the script in the wallpaper folder and its only one desktop icon))
   
    Posted by humpty on Dec. 02 2007,18:43  
        | Quote (roberts @ Dec. 02 2007,08:56) |  | So using this scheme every window manager has the same wallpaper? |  
  well, every window manager that has the xsri command in the .inc file will load it at X startup. infact, thinking about it, it's probably best if the .inc file just call set_wallpaper instead of the xsri command.
  anyway, i have combined set_wallpaper and reload_wallpaper into one script; /home/dsl/.dfmdesk/wallpaper/set_wallpaper
 | Code Sample  |   #!/bin/bash
  #set_wallpaper <file>
  #copy the wallpaper to a file called 'default' inside the desktop wallpaper folder and load it. #if no <file> is given, just reload 'default'
  if [ "$1" != "" ]; then  cp $1 /home/dsl/.dfmdesk/wallpaper/default fi xsri --scale-width=100 --scale-height=100 /home/dsl/.dfmdesk/wallpaper/default
 
  |  
 
  just double click set_wallpaper to reload it.
   
    Posted by jpeters on Dec. 03 2007,04:19  
        I'm having lots of fun with this script
  < http://jpeters.net/apps/screenshot.png >
   
    Posted by roberts on Dec. 03 2007,07:10  
        Nice. Seeing various wallpapers, reminds me of the difficulty that I have with my vision and aterm's transparency. While transparency is a cool feature it can, for me, be difficult to read when overlayed on some backgrounds. The transparency can be easily turned off by changing the .Xdefaults file in your home directory.
  Aterm*transparent: false
   
    Posted by ^thehatsrule^ on Dec. 03 2007,15:55  
        re: aterm -tr: for lighter/mixed backgrounds, I like to increase the shade amount i.e. with -sh
   
    Posted by humpty on Dec. 09 2007,06:25  
        i didn't know xsri was so versatile. here is the final script to wrap up.
  /home/dsl/.dfmdesk/wallpaper/set_wallpaper
 | Code Sample  |  
  #!/bin/bash
  #set_wallpaper <file>
  #copy the wallpaper to a file called 'default' inside the desktop wallpaper folder and load it. #if no <file> is given, just reload 'default'
  if [ "$1" != "" ]; then  cp $1 /home/dsl/.dfmdesk/wallpaper/default fi
  xsri	\ 	--color=black \ 	--scale-width=100 --scale-height=100 \ 	--keep-aspect \ 	--emblem \ 	/home/dsl/.dfmdesk/wallpaper/default \
  # xsri options # --scale-width=100 --scale-height=100 \ # --center-x --center-y \ # --keep-aspect \ # --color=black \ # --emblem=<image> \ # --emblem-alpha [0-255] \ # --tile=<image> \ # --tile-alpha [0-255] \ # --emboss \ # --geometry=[wxh][+x+y] \ # --color=#226622 \ # --color2=black \ # --vgradient \ # --hgradient \
 
  |  
  drag the file from a dfm folder onto the set_wallpaper icon.
  and don't forget to call set_wallpaper from your window manager .inc file for startup.
   
    Posted by humpty on Jan. 01 2008,03:57  
        Below is a lua version of my wallpaper/background loader I did over the hols (yeh yeh, you can tell I don't have a life).
  I may have gone a bit overboard here with the dragNdrop concept but basically set_wallpaper now allows commands either embedded in the filename or solo dragNdrop commands.
  So you can drop files named e.g mypic--reset--full-screen--keep-aspect.jpg
  Or you can individually dragNdrop e.g  mypic.jpg ++full_screen ++keep-aspect
  or highlight a few ++cmds to drop.
  The commands accumalate and are saved to default.opts and re-used until a '++reset' or '--reset' is issued.
  Just put this file in /home/dsl/.dfmdesk/wallpaper folder and run 'set_wallpaper __make' to make the solo (++)commands.
  Read the end of the file to see the commands supported.
  Also include '/home/dsl/.dfmdesk/wallpaper/set_wallpaper' in .xinitrc before the last line to load wallpaper at boot.
  (the default wallpaper is now called 'current')
 
 | Code Sample  |   #!/bin/lua
  -- set_wallpaper [file] [file--with-commands] [++solo-commands]
  -- current pic is called 'current' -- use cmd '++make' to make solo cmd files for dragNdrop -- last settings are kept in 'default.opts', use cmd '++reset' to clear -- -------------------------------------------------------------------------- -- functions
  function reset_defaults () -- note: if you edit these defaults, required is a space before the cmd  scalex  = ""  scaley  = ""  aspect  = ""  centerx = ""  centery = ""  color   = ""  color2  = ""  grad    = ""  tile    = ""  opts    = "" end
  function process_cmds (cmd)  -- tailored cmds  if (string.find (cmd, "--reset")) then     reset_defaults ()   print ("defaults reset")  end  if (string.find (cmd, "--full%-screen")) then  		 scalex=" --scale-width=100" 		 scaley=" --scale-height=100"  end		  if (string.find (cmd, "--full%-x"))  	  then scalex=" --scale-width=100" end  if (string.find (cmd, "--full%-y"))  	  then scaley=" --scale-height=100" end  if (string.find (cmd, "--black"))  	  then color= " --color=black" end
   -- standard xsri cmds (no parameters)  if (string.find (cmd, "--keep%-aspect")) then aspect  = " --keep-aspect" end  if (string.find (cmd, "--center%-x"))    then centerx = " --center-x" end  if (string.find (cmd, "--center%-y"))    then centery = " --center-y" end  if (string.find (cmd, "--hgradient"))    then grad    = " --hgradient" end  if (string.find (cmd, "--vgradient"))    then grad    = " --vgradient" end  if (string.find (cmd, "--tile"))    	  then tile    = " --tile" end
   -- cmds which require parameters  s,e,x = string.find (cmd, "--scale%-width=(%d+)")  if x then scalex = " --scale-width="..x end  s,e,y = string.find (cmd, "--scale%-height=(%d+)")  if y then scaley = " --scale-height="..y end
   s,e,c = string.find (cmd, "--color=([#%w]+)")  if c then color = " --color="..c end  s,e,c = string.find (cmd, "--color2=([#%w]+)")  if c then color2 = " --color2="..c end
  end --process_cmds -- -------------------------------------------------------------------------- -- main
  wcmd = "" i=1 while arg[i] ~= nil do   wcmd = wcmd.." "..arg[i]  i=i+1 end
  if wcmd == " ++make" then  os.execute ("touch ++black ++full-screen ++full-x ++full-y ++keep-aspect ++center-x ++center-y ++tile ++reset")  os.exit(0) end
  -- are these solo cmds or embedded in the filename ? if (string.find (wcmd, "++") or wcmd == "") then   wcmd = string.gsub (wcmd, "++", "--")  solo=true else solo=false  end
  -- load any filename, and copy it to 'current' if not solo then  os.execute ("cp "..wcmd.." /home/dsl/.dfmdesk/wallpaper/current") else print ("solo") end
  reset_defaults ()
  --load default opts fin=io.open("/home/dsl/.dfmdesk/wallpaper/default.opts", "r")  opts=fin:read() fin:close ()
  -- process default opts print ("defaults:"..opts) process_cmds (opts)
  -- add input opts print ("inputs  :"..wcmd) process_cmds (wcmd)
  opts=scalex..scaley..aspect..centerx..centery..color..color2..grad..tile print ("final   :"..opts)
  -- load current pic os.execute ("xsri "..opts.." /home/dsl/.dfmdesk/wallpaper/current")
  -- save as default opts fout=io.open("/home/dsl/.dfmdesk/wallpaper/default.opts", "w")  fout:write (opts, "\n") fout:close ()
  --tailored command options -- ++full-screen -- ++full-x -- ++full-y -- ++black
  -- xsri options implemented (see xsri --help for reference) -- --scale-width=100 --scale-height=100 -- --center-x --center-y -- --keep-aspect -- --tile -- --color=#226622 --color2=black -- --vgradient --hgradient
  -- xsri options not yet implemented -- --emblem=file -- --emblem-alpha [0-255] -- --geometry=[wxh][+x+y] -- --tile-alpha [0-255] -- --emboss
  |   
   
     |