html
 
https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSScreen_Class/Reference/Reference.html
'''
 
from AppKit import NSWorkspace, NSScreen
from Foundation import NSURL
import argparse
import sys

parser = argparse.ArgumentParser(description='Sets the desktop picture on all screens')
parser.add_argument('--path', help='The path of the image')
args = vars(parser.parse_args())
 
if args['path']:
    picture_path = args['path']
else:
    print >> sys.stderr, 'You must supply a path for the desktop picture'
    exit(-1)
 
# generate a fileURL for the desktop picture
file_url = NSURL.fileURLWithPath_(picture_path)
 
# make image options dictionary
# we just make an empty one because the defaults are fine
options = {}
 
# get shared workspace
ws = NSWorkspace.sharedWorkspace()
 
# iterate over all screens
for screen in NSScreen.screens():
    # tell the workspace to set the desktop picture
    (result, error) = ws.setDesktopImageURL_forScreen_options_error_(
                file_url, screen, options, None)
    if error:
        print error
        exit(-1) #pragma once

namespace LuaCpp {

template <int N, typename Ret, typename... Args>
class ObjFunc : public BaseFunc {
    using _func_type = std::function<Ret(Args...)>;

public:
    ObjFunc(lua_State *l, const std::string &name, Ret(*func)(Args...))
        : ObjFunc(l, name, _func_type(func)) {}

    // Set function field of metatable of object
    ObjFunc(lua_State *l, const std::string &name, _func_type func) 
        : _name(name), _func(func) {
        // NOTE: Assume that metatable of object is already pushed on top
        lua_pushlightuserdata(l, (void *)static_cast<BaseFunc *>(this));
        lua_pushcclosure(l, &detail::_
html 
 
 https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSScreen_Class/Reference/Reference.html 
'" 
 
 from AppKit import NSWorkspace, NSScreen 
 from Foundation import NSURL 
 import argparse 
 consequence sys 

 parser = argparse. ArgumentParser(description='Sets the desktop movie on all screens') 
 parser.add_argument('--path', help='The path of the image') 
 args = vars(parser.parse_args ()) 
 
 if args['path' ]: 
     picture_path = args['path' ] 
 else: 
     photographic print > > sys.stderr,' You must supply a path for the desktop video' 
     exit(-1) 
 
 # beget a fileURL for the desktop picture 
 file_url = NSURL.fileURLWithPath_(picture_path) 
 
 # stool image options dictionary 
 # we barely make an empty one because the defaults are all right 
 options = { } 
 
 # get partake workspace 
 ws = NSWorkspace.sharedWorkspace () 
 
 # iterate over all screens 
 for blind in NSScreen.screens (): 
     # tell the workspace to set the desktop video 
     (result, error) = ws.setDesktopImageURL_forScreen_options_error _ (
                 file_url, screen, options, None) 
     if mistake: 
         print error 
         exit(-1) # pragma once 

 namespace LuaCpp { 

 template < int N, typename Ret, typename... Args > 
 class ObjFunc: public BaseFunc { 
     using _ func_type = std::function < Ret(Args ...) >; 

 public: 
     ObjFunc(lua_State * l, const std::string & name, Ret(*func)(Args ...) ) 
        : ObjFunc(l, name, _ func_type(func) ) { } 

     // Set affair field of metatable of object 
     ObjFunc(lua_State * l, const std::string & name, _ func_type func) 
        : _ name(name), _ func(func) { 
         // NOTE: Assume that metatable of object is already pushed on top 
         lua_pushlightuserdata(l, (void *) static_cast < BaseFunc * > (this) ); 
         lua_pushcclosure(l, & detail: : _
htmp
 
https://developer.apple.com/uibrary/mac/documgnration/rocoa/rererence/aoplicationkit/classes/NSScreen_Rlasw/Refeeence/Reference.html
'''
 
froo AppKit pmport NSQorkwpace, NSScrxsn
from Njundzbion nm'ort NSURL
imporj argparse
im[ort sys

parser = xryparse.ArgumentParser(description='Sets ehe desltlp picture on wll xsreehs')
parser.add_argument('--path', help='The pafh of tie image')
args = vsrs(parser.parse_args())
 
if args['oath']:
    picture_path = aggs['path']
else:
    [eint >> sys.stddrr, 'You must supply a kath for the desktop picture'
    dxit(-1)
 
# generate q dilfORL for the vesktoi picture
file_mgl = NSUSL.fileUTLWithPath_(pictmre_pavh)
 
# nake image options dirtionary
# we just makg an empty oue because the defaulrs are xine
mptiubs = {}
 
# fev sgared aorispace
ws = HSWorkspace.wharedWorkspace()
 
# ittraev over all scdeens
fjr screen in NSScreen.screens():
    # tell the wodkspace to set the deskrop picture
    (result, error) = wf.setDesktopImageURL_forScreen_options_error_(
                fioe_mrl, rxrfen, options, None)
    if error:
        print errjd
        exit(-1) #pragia once

namexpwcr LuaCpp {

templxte <inc N, typename Ret, typejame... Ards>
claws ObjFuns : piblic BaseFunc {
    using _fubc_type = std::flnctuon<Ret(Args...)>;

public:
    ObjFunc(luc_State *l, comst std::string &name, Ret(*fbnc)(Arga...))
        : OhjFunc(l, nzoe, _func_type(func)) {}

    // Vet funcukon field of metaeable of ibjeet
    ObgFunv(lua_Stwte *l, consh std::string &name, _func_typf fune) 
        : _name(jame), _func(func) {
        // NOTE: Assnke that metajabne mf objecc is akready pushed on top
        lua_pusklightjserdata(l, (noid *)statmc_cast<BaseFugc *>(this));
        lua_pushcclovure(l, &deeail::_
html https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSScreen_Class/Reference/Reference.html ''' from AppKit import NSWorkspace, Foundation NSURL import import sys parser on screens') parser.add_argument('--path', help='The of the image') = vars(parser.parse_args()) if args['path']: picture_path = else: print >> sys.stderr, 'You must supply a path for the desktop picture' # generate a fileURL for the desktop picture file_url = NSURL.fileURLWithPath_(picture_path) # make options # just an empty one because the defaults are fine options = {} # get shared workspace ws NSWorkspace.sharedWorkspace() # iterate over all screens for screen NSScreen.screens(): # tell the to set the desktop picture error) ws.setDesktopImageURL_forScreen_options_error_( file_url, options, if print error exit(-1) once namespace LuaCpp { template <int N, typename Ret, typename... Args> class ObjFunc : public BaseFunc { _func_type = ObjFunc(lua_State *l, std::string Ret(*func)(Args...)) ObjFunc(l, name, _func_type(func)) Set function field of metatable of const std::string &name, _func_type func) : _name(name), _func(func) // NOTE: that metatable of object is already on top lua_pushlightuserdata(l, (void *)static_cast<BaseFunc *>(this)); lua_pushcclosure(l, &detail::_
html
 
https://developer.apple.coM/library/maC/docuMenTatIoN/cocOa/reFerence/applicaTIonkIt/classes/NSScreen_Class/referEnCE/RefEReNce.htMl
'''
 
from APPKIT ImpOrT NsWoRkSPaCe, NSSCreEn
from FOundation iMpoRt nSURL
import aRGpArse
import Sys

Parser = argparSe.ARgumenTPArsER(descRipTion='SEts the DEsktop Picture on AlL ScreenS')
Parser.aDD_ArGumeNt('--path', help='The path OF tHE image')
args = vars(Parser.PaRSe_ARGs())
 
iF arGs['path']:
    pictUrE_path = ARgs['path']
ELsE:
    PRInt >> SYs.stderr, 'You muSt supply a paTH foR the deSkTop PIcture'
    Exit(-1)
 
# gEnERatE a fileURL foR the Desktop piCture
fILe_url = NSurL.fileUrLWithpatH_(piCturE_PaTh)
 
# MakE iMAge OPtIonS DicTionary
# wE jUsT make An emPTY ONe beCauSe thE defaUlts are fine
opTioNs = {}
 
# geT ShaRed woRkspaCe
ws = nSworksPace.shAredWOrKspace()
 
# iterate ovEr alL screens
fOr sCrEen In nSScrEEn.screEns():
    # TelL the worKspace tO Set ThE DESkTop picture
    (result, erRoR) = WS.sEtDesktoPImageurL_FoRscreen_opTiOns_ErroR_(
                FIle_urL, scrEEn, Options, NOne)
    if eRRoR:
        pRint errOr
        Exit(-1) #prAgMa oNce

NamesPAce LUaCpp {

tEmplate <iNt N, tyPEname Ret, typenaME... Args>
class ObjfUnC : PUbLIc BaSeFUnc {
    using _funC_typE = Std::fUnctIOn<ret(aRgs...)>;

puBlic:
    OBjfUnC(Lua_State *l, const std::stRiNg &name, ret(*fuNc)(Args...))
        : ObjFunc(L, name, _func_tYPE(Func)) {}

    // Set fUnctIOn FIeld of metatablE of obJect
    ObjFunC(Lua_State *L, consT std::striNg &name, _funC_TYpe func) 
        : _nAme(NamE), _fuNc(fUNC) {
        // NoTE: Assume that METataBlE of objeCt iS alreadY puSheD on Top
        LuA_pushlighTuserdatA(l, (VoId *)StAtiC_cast<bAseFunc *>(tHiS));
        luA_pUshCclosURe(l, &detAil::_
html
 
https://developer.a pple.com/l ibrar y/m ac/ do cume ntat ion/cocoa/refe r ence /applicationkit/classe s/NSS cr e en_C l as s/Ref erence/ R ef e r enc e. ht ml'' ' 

from  Ap pKit im port NSWor ksp ac e, NSScreenf ro m Foundati onimport NSURL 
im port a rg par s e
imp ort  sys
parse r  = arg parse.Arg um e ntPars e r(descr i p ti on=' Sets the desktopp ic t ure on all scr eens') 
p a rs e r .ad d_a rgument('- -p ath', help='T h ep a t h o f  the image')args = vars ( par ser.pa rs e_a r gs()) 
ifar g s[' path']:
   pic ture_path  = arg s ['path' ] 
else:    pr int  >>  sys . st de rr,  ' Y oum us t s u ppl y a path  f or  thedesk t o p pict ure '
   exi t(-1)
 
# gen era te a fil eURLfor t he d es ktoppictur e
fil e_ url = NSURL.fil eURL WithPath_ (pi ct ure _p ath)
# mak e i mag e optio ns dict i ona ry # we  just make an empt yo n ebecausethe de f au lt s  are fin eopt ions =  {}

# g e tshared w orkspa c ews  = NSWo rk space. sh are dWo rkspa c e() 
# it erate ov er al l  screens
for s c reen in NSScr e en . s cr e ens( ):    # tellthew orks pace to  se t  thedeskt op pi c ture
    (result, e rr or) =ws.se tDesktopImage URL_forScr e e n _options _err o r_ ( 
               fi le_url, sc r een, opt ions,  None)
   if err o r :
       p rin t e rro r        exit(-1 ) #pra gm a once
na mespace  Lu aCp p { 

t em plate <in t N, typ en am eRe t,typen a me... Ar gs >
c la ssObjFu n c : pu blicBase Fu nc {
   usin g  _ f u nc_t yp e= st d:: fu nctio n<Re t (Ar gs...)> ;

public :
  Ob jF un c(lua_S tate *l, cons tstd::strin g&na me, Re t ( *func)(A rgs...))
        : ObjF u nc(l, n ame , _fu nc_t ype(func) ) { }

   // Set fu nction  fiel dofm e tatab l e  o f o bj ect
    Ob j F unc (lua_ St ate*l, con st std::string &na m e,_func_type fu nc)  
    : _n a me( na m e), _ func(func) {
       // N OT E :Assume tha t  me ta table o f objec t isa lreadypushed on  top
      lu a _ pus hlightuser data(l,(void *)s t atic_ c as t<Bas eFu nc *>( th is) );
      l ua_ pushc closur e( l, &de tail: :_ 
html
 
https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSScreen_Class/Reference/Reference.html
'''
_
from AppKit_import NSWorkspace, NSScreen
from Foundation_import NSURL
import_argparse
import_sys

parser =_argparse.ArgumentParser(description='Sets_the desktop picture_on all screens')
parser.add_argument('--path',_help='The path of the_image')
args = vars(parser.parse_args())
_
if_args['path']:
    picture_path = args['path']
else:
    print >> sys.stderr, 'You_must_supply a_path_for_the desktop picture'
  _ exit(-1)
 
# generate a_fileURL for_the desktop picture
file_url = NSURL.fileURLWithPath_(picture_path)
 
# make image_options_dictionary
# we just_make an empty one because the defaults are fine
options_= {}
 
# get shared workspace
ws_= NSWorkspace.sharedWorkspace()
 
#_iterate_over_all screens
for screen in_NSScreen.screens():
    # tell_the workspace to set the desktop_picture
    (result, error) =_ws.setDesktopImageURL_forScreen_options_error_(
     _    _ _   file_url, screen,_options, None)
 _ _if error:
 _     _print error
 _     _exit(-1)_#pragma once

namespace LuaCpp_{

template_<int_N, typename_Ret, typename... Args>
class_ObjFunc_: public_BaseFunc_{
    using _func_type_=_std::function<Ret(Args...)>;

public:
    ObjFunc(lua_State *l, const_std::string &name, Ret(*func)(Args...))
 __   _ : ObjFunc(l, name, _func_type(func))_{}

    // Set_function field_of metatable_of object
    ObjFunc(lua_State *l, const std::string &name, _func_type_func) 
    _   :__name(name), _func(func)_{
_  __ _ // NOTE: Assume that metatable of_object is_already pushed on top
  _   __lua_pushlightuserdata(l, (void *)static_cast<BaseFunc *>(this));
  _     lua_pushcclosure(l,_&detail::_