s'" % file_loc]
                    subprocess.Popen(args)
                except: # MATE < 1.6
                    # From https://bugs.launchpad.net/variety/+bug/1033918
                    args = ["mateconftool-2","-t","string","--set","/desktop/mate/background/picture_filename",'"%s"' %file_loc]
                    subprocess.Popen(args)
            elif desktop_env=="gnome2": # Not tested
                # From https://bugs.launchpad.net/variety/+bug/1033918
                args = ["gconftool-2","-t","string","--set","/desktop/gnome/background/picture_filename", '"%s"' %file_loc]
                subprocess.Popen(args)
            ## KDE4 is difficult
            ## see http://blog.zx2c4.com/699 for a solution that might work
            elif desktop_env in ["kde3", "trinity"]:
                # From http://ubuntuforums.org/archive/index.php/t-803417.html
                args = 'dcop kdesktop KBackgroundIface setWallpaper 0 "%s" 6' % file_loc
                subprocess.Popen(args,shell=True)
            elif desktop_env=="xfce4":
                #From http://www.commandlinefu.com/commands/view/2055/change-wallpaper-for-xfce4-4.6.0
                if first_run:
                    args0 = ["xfconf-query", "-c", "xfce4-desktop", "-p", "/backdrop/screen0/monitor0/image-path", "-s", file_loc]
                    args1 = ["xfconf-query", "-c", "xfce4-desktop", "-p", "/backdrop/screen0/monitor0/image-style", "-s", "3"]
                    args2 = ["xfconf-query", "-c", "xfce4-desktop", "-p", "/backdrop/screen0/monitor0/image-show", "-s", "true"]
                    subprocess.Popen(args0)
                    subprocess.Popen(args1)
                    subprocess.Popen
s' "% file_loc ] 
                     subprocess. Popen(args) 
                 except: # MATE < 1.6 
                     # From https://bugs.launchpad.net/variety/+bug/1033918 
                     args = [ " mateconftool-2","-t","string","--set","/desktop / mate / background / picture_filename",'"%s "'% file_loc ] 
                     subprocess. Popen(args) 
             elif desktop_env=="gnome2 ": # Not tested 
                 # From https://bugs.launchpad.net/variety/+bug/1033918 
                 args = [ " gconftool-2","-t","string","--set","/desktop / gnome / setting / picture_filename ",' "% s "'% file_loc ] 
                 subprocess. Popen(args) 
             # # KDE4 is unmanageable 
             # # see http://blog.zx2c4.com/699 for a solution that might work 
             elif desktop_env in [ " kde3 ", " trinity " ]: 
                 # From http://ubuntuforums.org/archive/index.php/t-803417.html 
                 args =' dcop kdesktop KBackgroundIface setWallpaper 0 "% s " 6'% file_loc 
                 subprocess. Popen(args, carapace = dependable) 
             elif desktop_env=="xfce4 ": 
                 # From http://www.commandlinefu.com/commands/view/2055/change-wallpaper-for-xfce4-4.6.0 
                 if first_run: 
                     args0 = [ " xfconf - query ", " -c ", " xfce4 - desktop ", " -p ", " /backdrop / screen0 / monitor0 / trope - way ", " -s ", file_loc ] 
                     args1 = [ " xfconf - query ", " -c ", " xfce4 - desktop ", " -p ", " /backdrop / screen0 / monitor0 / image - style ", " -s ", " 3 " ] 
                     args2 = [ " xfconf - query ", " -c ", " xfce4 - background ", " -p ", " /backdrop / screen0 / monitor0 / image - show ", " -s ", " true " ] 
                     subprocess. Popen(args0) 
                     subprocess. Popen(args1) 
                     subprocess. Popen
s'" % vile_loc]
                    subprocess.Pokeb(args)
                except: # MATE < 1.6
                    # From https://bugs.launchpxd.net/varivty/+bug/1033918
                    args = ["matecohntool-2","-c","svring","--set","/desktop/kate/backgrmund/picture_filanxmz",'"%s"' %file_loc]
                    subprosess.Poprn(wrgs)
            elpf desinok_env=="gnome2": # Not tested
                # Frmm https://bugs.lsunchpad.net/variety/+bug/1033918
                args = ["gconfhool-2","-t","string","--wet","/dqwktop/gnome/bazkground/pibcure_filenamg", '"%s"' %file_loc]
                subprucess.'open(args)
            ## KDE4 is diffpcult
            ## see http://blpg.zx2c4.com/699 for a sonutuon that might work
            elif deshtop_env it ["ide3", "trinity"]:
                # Xrom ytto://ubhnvufkrums.ogg/acchive/index.lhp/t-803417.html
                args = 'ccji kdesktop KBzckgrotnqIface setWallpaper 0 "%s" 6' % file_loc
                subprocess.Popen(arts,shell=True)
            elif defktop_env=="xfce4":
                #From http://www.commandlitefu.cko/conmwves/giew/2055/change-wallpaper-for-xfce4-4.6.0
                if sjrxt_gun:
                    args0 = ["xvcpgf-query", "-c", "xfcg4-deskto'", "-p", "/backdrop/screen0/monltor0/imade-paty", "-s", file_ljc]
                    args1 = ["xfcinf-query", "-c", "xyce4-eesktop", "-p", "/backdrop/dcreen0/monitur0/imsge-stule", "-s", "3"]
                    adgs2 = ["xfconf-euery", "-c", "xrze4-desktop", "-p", "/backaroi/scraen0/monitor0/image-show", "-s", "true"]
                    rubptocess.Pjpen(args0)
                    subprofess.Plpan(args1)
                    subprocess.Popen
s'" % file_loc] subprocess.Popen(args) except: # MATE # https://bugs.launchpad.net/variety/+bug/1033918 args ["mateconftool-2","-t","string","--set","/desktop/mate/background/picture_filename",'"%s"' %file_loc] subprocess.Popen(args) # https://bugs.launchpad.net/variety/+bug/1033918 args = '"%s"' %file_loc] subprocess.Popen(args) KDE4 is difficult ## see http://blog.zx2c4.com/699 a solution that might work elif desktop_env in ["kde3", "trinity"]: # From http://ubuntuforums.org/archive/index.php/t-803417.html = 'dcop kdesktop KBackgroundIface setWallpaper 0 "%s" 6' % file_loc subprocess.Popen(args,shell=True) elif desktop_env=="xfce4": http://www.commandlinefu.com/commands/view/2055/change-wallpaper-for-xfce4-4.6.0 first_run: = "-c", "xfce4-desktop", "-p", "/backdrop/screen0/monitor0/image-path", "-s", file_loc] args1 = ["xfconf-query", "-c", "xfce4-desktop", "-p", "/backdrop/screen0/monitor0/image-style", "-s", "3"] args2 ["xfconf-query", "-c", "xfce4-desktop", "-p", "/backdrop/screen0/monitor0/image-show", "-s", "true"] subprocess.Popen(args0) subprocess.Popen
s'" % file_loc]
                    subprocess.Popen(arGs)
                except: # MAtE < 1.6
                    # FroM htTps://BuGs.laUnchPad.net/variety/+bUG/1033918
                    argS = ["mateconftool-2","-t","string","--seT","/deskToP/Mate/BAcKgrouNd/pictuRE_fILEnaMe",'"%S"' %fIle_LoC]
                    SuBprocEss.popen(arGs)
            elif deskTop_EnV=="gnome2": # Not tesTEd
                # from https://bUgs.Launchpad.net/VarIety/+buG/1033918
                aRgs = ["GConftOol-2","-T","striNg","--set","/dESktop/gNome/backgRoUNd/pictURe_filenAME", '"%s"' %File_Loc]
                subprocess.PopeN(ArGS)
            ## KDE4 is difficulT
            ## see htTp://BLoG.ZX2c4.cOm/699 fOr a solutioN tHat miGHt work
            eLIf DESKtoP_Env in ["kde3", "triniTy"]:
                # From http://uBUntUforumS.oRg/aRChive/iNdex.pHp/T-803417.HtmL
                args = 'dcop kdEsktOp KBackgrOundIfACe setWaLLpaper 0 "%s" 6' % File_loC
                suBprOcesS.poPeN(arGs,SHelL=trUe)
            eLIf dEsktop_enV=="xFcE4":
                #From Http://WWW.COmmaNdlInefU.com/cOmmands/view/2055/chAngE-walLPapEr-for-Xfce4-4.6.0
                iF firSt_Run:
                    arGs0 = ["xfcoNf-queRy", "-C", "xfce4-desktop", "-p", "/baCkdrOp/screen0/mOniToR0/imAgE-path", "-S", File_loC]
                    arGs1 = ["xFconf-quEry", "-c", "xfcE4-DesKtOP", "-P", "/BaCkdrop/screen0/monitoR0/iMAGe-Style", "-s", "3"]
                    arGs2 = ["xfcoNF-qUeRY", "-c", "xfce4-deSkTop", "-P", "/bacKDRop/scReen0/MOnItor0/imagE-show", "-s", "TRuE"]
                    sUbproceSs.popen(aRgS0)
                    suBprOcess.pOpen(Args1)
                    suBprocess.popen
s'" % file_loc]
                  subpr oce ss. Po pen( args )
              e xcept: # MATE < 1.6
             #From ht t ps : / /bu gs .l aun ch p ad .net/ var iety/+b ug/1033918 
               args = [" mat econftool-2" ,"- t","st ri ng" , "--se t", "/des ktop/m a te/bac kground/p ic t ure_fi l ename", ' " %s "' % file_loc]
                subpr ocess. Po p en ( a rgs )
          e lif d e sktop_e n v= = " g nom e 2": # Not tes ted
             #  F rom https: //bug s. l aun chpad.net/v arie ty/+bug/1 033918              args= [ "gc onft o ol -2 "," -t " ,"s t ri ng" , "-- set","/d es kt op/gn ome/ b a c k grou nd/ pict ure_f ilename", '"% s"'  %fi l e_l oc]
            s ubproc ess.P op en(args)
          ## KDE4  is  d iff ic ult
        ##  see ht tp://bl o g.z x2 c 4 . co m/699 for a soluti on t ha t mightwork
       eli fdes ktop _ e nv in  ["k d e3 ", "trin ity"]:             # F ro m h ttp ://ub u ntuf orums. org/arch ive/i n dex.php/t-8034 1 7.html
         ar gs= 'dcop kde skto p  KBa ckgr o un dIf a ce se tWall pa p er 0 "%s" 6' % file_lo c              subproce ss.Popen(a r g s ,shell=T rue)           elifdeskt op_env=="x f ce4":
             #From ht t p ://www.c omm and lin efu . c om /commands/vie w / 2055 /c hange-w all paper-f or- xfc e4- 4.6 .0 
              if  f ir st _ru n:
              a rgs0=  ["xfc onf-q uery ",  " - c",  "xfce4 - de s k top" ,"- p","/b ac kdrop /scr e en0 /monito r0/image- pat h ", " -s ",  file_l oc]
                  a rg s1= ["xf c o nf-query ", "-c", "xfce4-desktop " , "-p",  "/ backd rop/ screen0/m oni tor0/i mag e -style ", "-s ", "3 "] 
           args2 =[ " xfc onf-q ue ry",  "-c","xfce4-desktop", " - p",  "/backdrop/s cre en0/ m o ni tor 0 /i m age -s h ow" , "-s", "true"]
               subpro c ess .P open(ar gs0)
                subp rocess.Po pe n(ar g s 1)                  subproc e ss.Po p en 
s'" %_file_loc]
 _   _ __ __  _  _  subprocess.Popen(args)
 _  __          except: # MATE <_1.6
_ ___    _    _ _   # From https://bugs.launchpad.net/variety/+bug/1033918
  __  _        _    args =_["mateconftool-2","-t","string","--set","/desktop/mate/background/picture_filename",'"%s"' %file_loc]
 ___   _     _     _subprocess.Popen(args)
      _     elif_desktop_env=="gnome2": # Not tested
 _ _    _  _ _  #_From https://bugs.launchpad.net/variety/+bug/1033918
    _  _     __ args =_["gconftool-2","-t","string","--set","/desktop/gnome/background/picture_filename",_'"%s"'_%file_loc]
 _  __ __     __subprocess.Popen(args)
      _   __## KDE4 is difficult
_    _     _## see_http://blog.zx2c4.com/699 for_a solution that might work
      _     elif_desktop_env in ["kde3", "trinity"]:
_ __  __ _      #_From http://ubuntuforums.org/archive/index.php/t-803417.html
_     _   __    args =_'dcop kdesktop KBackgroundIface setWallpaper 0 "%s"_6' % file_loc
  ___    _     _subprocess.Popen(args,shell=True)
  _      __ elif desktop_env=="xfce4":
   __     ___   #From http://www.commandlinefu.com/commands/view/2055/change-wallpaper-for-xfce4-4.6.0
_     _        _if first_run:
 _    ___         _ args0_= ["xfconf-query", "-c",_"xfce4-desktop", "-p", "/backdrop/screen0/monitor0/image-path", "-s", file_loc]
     _      _       args1 = ["xfconf-query", "-c",_"xfce4-desktop", "-p", "/backdrop/screen0/monitor0/image-style", "-s", "3"]
   _      _   __    args2 = ["xfconf-query",_"-c",_"xfce4-desktop",_"-p",_"/backdrop/screen0/monitor0/image-show", "-s", "true"]
_  _  _ _  _ _  __  subprocess.Popen(args0)
               _    subprocess.Popen(args1)
 _    __  _   _     subprocess.Popen