Greetings from Jersey ( be afraid ). Do folks have user pages on this wiki?
I'm like the third. Seems kind of lonely.
I'm enjoying open box, though haven't taken the plunge to go stand alone;
gnome has me by a toe or two.
I love the pipemenus, brilliant idea.
I've thrown some stuff up on the page. I'm curious as to the etiquette
of the source posting. Everyone seems to host their own, but wikis seem
made of code collecting. Also, if the host should go away, it would be
nice to have a reference in the main project. With that in mind, I'm
going to put some scripts on this page and see if the powers that be are
cool with it.
As I started playing with pipemenus, it became clear that a lot of code
could be reused. While having everything in once script is nice, having
a basic library to do the work for new scripts also has a lot going for
it. I used all manner of prefixes, ob, pm, obpm, etc. Ultimately, I
wanted something unique that wouldn't step on other scripts. I settled
on BOP, mostly because the name amused me.
BOP is short for Baavgai's Openbox Pipemenus. Yeah, using your own name
is kind of tacky; but I've become fond of BOP. :p These are just a
sample of the files, with more on the way. Go to that web share for the
complete list. Enjoy.
# Baavgai's Openbox Pipemenus (BOP)# BOP Common Library: All "BOP" files need this# current version at http://chaingang.org/code/linux/obscripts/boplib.pyimportre,binasciiFileManagerMask="nautilus %s"classMenuWriter:def__init__(self,menuPrefix):self.idCount=0self.menuPrefix=menuPrefixdef__GetNextMenuId(self):self.idCount+=1return'bop_%s_%s'%(self.menuPrefix,self.idCount)defPrintMenuBegin(self,label):print'<menu id="%s" label="%s">'%(self.__GetNextMenuId(),EscEntity(label))defPrintMenuEnd(self):print'</menu>'defPrintMenu(self,label,func):self.PrintMenuBegin(label)func()self.PrintMenuEnd()defPrintExecMenu(self,label,execute):print'<menu id="%s" label="%s" execute="%s" />'%(self.__GetNextMenuId(),EscEntity(label),EscEntity(execute))defEscEntity(text):for(k,v)in[['&','&'],['<','<'],['>','>'],["'",'''],['"','"']]:text=text.replace(k,v)returntextdefEscUri(text):defUriRep(match):returnbinascii.unhexlify(match.group(0).replace('%',''))text=re.sub('\%..',UriRep,text)text=text.replace('_','__')returntextdefPrintEmptyItem(label):print'<item label="%s"></item>'%EscEntity(label)defPrintExecItem(label,cmd):print'<item label="%s">'%EscEntity(label)print'<action name="Execute"><execute>%s</execute></action>'%EscEntity(cmd)print'</item>'defPrintFileManagerItem(label,uri):PrintExecItem(label,FileManagerMask%uri)defPrintFileHeadFoot(func):print'<?xml version="1.0" encoding="UTF-8"?>'print'<openbox_pipe_menu>'func()print'</openbox_pipe_menu>'defGetLabelPath(path):cmdBits=path.split('/')label=cmdBits[len(cmdBits)-1]iflen(cmdBits)>2:server=cmdBits[2].strip()if(server):label+=' on '+serverreturn(EscUri(label),path)
#!/usr/bin/env python# Baavgai's Openbox Pipemenus (BOP)# BOP Gnome Bookmarks## current version at http://chaingang.org/code/linux/obscripts/bop_gbook.py# requires boplib.py found at http://chaingang.org/code/linux/obscripts/boplib.pyfromboplibimport*importosdefGetMenuSequence():return1100defGetMenuName():return'Gnome Bookmarks'defShowMenu():defProcessBookmarkLine(line):bookBits=line.strip().split(" ")iflen(bookBits)==2:(path,label)=bookBitslabel=EscUri(label)else:(label,path)=GetLabelPath(bookBits[0])PrintFileManagerItem(label,path)fileName=os.path.expanduser('~/.gtk-bookmarks')ifos.path.exists(fileName):map(ProcessBookmarkLine,open(fileName).readlines())if__name__=='__main__':PrintFileHeadFoot(ShowMenu)
#!/usr/bin/env python# Baavgai's Openbox Pipemenus (BOP)# BOP Gnome Menu## current version at http://chaingang.org/code/linux/obscripts/bop_gmenu.py# requires boplib.py found at http://chaingang.org/code/linux/obscripts/boplib.pyfromboplibimport*importgtk,gmenudefGetMenuSequence():return1000defGetMenuName():return'Gnome Menu'defShowMenu():mw=MenuWriter('menu')defWalkMenuTreeBranch(node):forchildinnode.contents:ifisinstance(child,gmenu.Directory):WalkMenuTree(child)ifnotisinstance(child,gmenu.Entry):continueifchild.type==gmenu.TYPE_ENTRY:PrintExecItem(child.name,child.get_exec())defWalkMenuTree(node):mw.PrintMenuBegin(node.name)WalkMenuTreeBranch(node)mw.PrintMenuEnd()WalkMenuTreeBranch(gmenu.lookup_tree("applications.menu",gmenu.FLAGS_INCLUDE_EXCLUDED).root)if__name__=='__main__':PrintFileHeadFoot(ShowMenu)
I think I do a "df -h" at least once a day, sometimes many if downloading ISOs.
This is a job for awk! Does anyone use awk anymore? It's actually kind of fun.