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 \ |
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 |