You are not logged in.
ok ive just discovered the joys of pipe menus
and as there doesnt seem to be a crunchbang forum thread so i thought i would start one.
ok heres mine, used for controlling MPD
#!/usr/bin/env python
#
# Author: Ben Holroyd <holroyd.ben@gmail.com>
# License: GPL 3.0+
#
# This script requires python-mpd
#
# Usage:
# Put an entry in ~/.config/openbox/menu.xml:
# <menu id="mpd" label="MPD" execute="~/.config/openbox/scripts/ompb.py" />
#
import mpd, os, sys, socket
mpdport = 6600
musicfolder ='/home/ben/music/'
filelist = True #potentially slow and unwieldy with a large collection of music
playlist = True #same for this
program = sys.argv[0]
client = mpd.MPDClient()
try:
client.connect("localhost", mpdport)
except socket.error:
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
print "<openbox_pipe_menu>"
print " <item label=\"MPD not running, click to start\">"
print " <action name=\"Execute\"><execute>mpd</execute></action>"
print " </item>"
print "</openbox_pipe_menu>"
sys.exit(0)
song = client.currentsong()
stats = client.stats()
status = client.status()
def play():
if status['state'] == "stop" or status['state'] == "pause":
client.play()
elif status['state'] == "play":
client.pause()
def volume(vol):
if vol == "up":
client.setvol(int(status['volume'])+10)
elif vol == "down":
client.setvol(int(status['volume'])-10)
try:
if (sys.argv[1] == "play"): play()
elif (sys.argv[1] == "stop"): client.stop()
elif (sys.argv[1] == "prev"): client.previous()
elif (sys.argv[1] == "next"): client.next()
elif (sys.argv[1] == "add"): client.add(sys.argv[2]); client.play()
elif (sys.argv[1] == "clear"): client.clear()
elif (sys.argv[1] == "volume"): volume(sys.argv[2])
elif (sys.argv[1] == "playlist"):
client.delete(client.playlist().index(sys.argv[2]))
elif sys.argv[1] == "random":
client.random(int(not int(client.status()['random'])and True or False))
elif sys.argv[1] == "repeat":
client.repeat(int(not int(client.status()['repeat'])and True or False))
except IndexError:
pass
def item_entry(indent, label, option = '', song = ''):
"""label = label on menu, option = play/pause/stop etc, song = path to song """
print "%s<item label=\"%s\">"%(indent, label)
print "%s <action name=\"Execute\"><execute>%s %s '%s'</execute></action>" % (indent, program, option, song)
print "%s</item>" % (indent)
def file_walk(dir,indent):
""" walks through music directory building a menu to view albums"""
files = os.listdir(dir)
files.sort()
for file in files:
path = os.path.join(dir,file)
if os.path.isdir(path):
print "%s<menu id=\"%s\" label=\"%s\">"%(indent, file, file)
item_entry(indent+' ','Add all to playlist','add' ,path.replace(musicfolder,''))
print "%s <separator />" % indent
file_walk(path,indent+' ')
print "%s</menu>" % indent
else:
item_entry(indent,file,'add',path.replace(musicfolder,''))
indent = indent[2:]
def track_info(label):
print " <menu id=\"%s\" label=\"%s\">"%(label,label)
print " <item label=\"Artist: %s\"/>" % song['artist']
print " <item label=\"Album: %s\"/>" % song['album']
print " <item label=\"Tracklength: %.2f\"/>" % ((int(song['time'])/60)+(int(song['time'])%60.0/100))
print " <item label=\"Track: %s\"/>" % song['track']
print " <item label=\"filetype: %s\"/>" % song['file'][song['file'].rfind('.')+1:]
#print " <item label=\"Genre: %s\"/>" % song['genre']
print " </menu>"
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
print "<openbox_pipe_menu>"
if status['state'] != "stop":
track_info("Playing: %s - " % song['artist'])
track_info(song['title'])
print " <separator />"
print " <item label=\"Status: %s\"/>" % {'play':'Playing','pause':'Paused','stop':'Stopped'}[status['state']]
print " <separator />"
item_entry(' ', 'Play/Pause', 'play')
item_entry(' ', 'Stop', 'stop')
item_entry(' ', 'Prev', 'prev')
item_entry(' ', 'Next', 'next')
print " <separator />"
if filelist == True:
print " <menu id=\"Albums\" label=\"Albums\">"
file_walk(musicfolder,' ')
print " </menu>"
print " <separator />"
if playlist == True:
print " <menu id=\"Playlist\" label=\"Playlist\">"
print " <item label=\"Click to remove from playlist\"/>"
print " <separator />"
for entries in client.playlist():
item_entry(' ', entries, 'playlist', entries)
print " </menu>"
print " <separator />"
item_entry(' ', 'Clear Playlist', 'clear')
item_entry(' ', 'Random %s' % (int(status['random']) and '[On]' or '[Off]'), 'random')
item_entry(' ', 'Repeat %s' % (int(status['repeat']) and '[On]' or '[Off]'), 'repeat')
print " <menu id=\"volume\" label=\"Volume [%s]\">" % (int(status['volume']) > 0 and status['volume']+'%' or 'mute')
item_entry(' ', 'Volume + 10\% ', 'volume up')
item_entry(' ', 'Volume - 10\%', 'volume down')
print " </menu>"
print " <separator />"
print " <menu id=\"stats\" label=\"Database Stats\">"
print " <item label=\"Artists in database: %s\"/>" % stats['artists']
print " <item label=\"Albums in database: %s\"/>" % stats['albums']
print " <item label=\"Songs in database: %s\"/>" % stats['songs']
print " </menu>"
print "</openbox_pipe_menu>"to use you need to add an entry to ~/.config/openbox/menu.xml
(also accessible through the menu preferences-->openbox config --> edit menu.xml)
something like
<menu id="mpd" label="MPD" execute="path/to/ompb.py"/>Last edited by benj1 (2009-09-16 19:54:07)
- - - - - - - - Wiki Pages - - - - - - -
#! install guide *autostart programs, modify the menu & keybindings
configuring Conky *installing scripts
Offline
Im stickying this topic and moving it to the Openbox section 
Note: ** Please read before posting **
BTW if you wish to contact me, send me an e-mail instead of a PM.
Offline
cool thanks 
- - - - - - - - Wiki Pages - - - - - - -
#! install guide *autostart programs, modify the menu & keybindings
configuring Conky *installing scripts
Offline
I have a semi-out of control pipe menu addiction...
Quodlibet controler, RSS feeds of Crunchbang forums, Weather, Gmail....
I found them all here....
http://icculus.org/openbox/index.php/Openbox:Pipemenus
Website 500px DeviantArt
God never ends anything on a negative; God always ends on a positive. -- Edwin Louis Cole --
Offline
I just found a list on this and trying to start for a new one. I will just keep you updated on this.
I'm still searching for more information about this.
great thanks!
Offline
I'm sure someone else has already thought of this, but I didn't see it mentioned. You can use the 'places' pipe menu to simplify menu.xml and system administration.
I made a directory in /usr/ called "launchers" and to it I added a bunch of shortcuts to the programs I wanted. Then I put:
<menu execute="obpipemenu-places /usr/launchers" id="launch" label="Programs"/>into the menu.xml of each user. Now not only can I edit the menu quickly and easily with my file manager (by drag-and-drop or with symlinks by cli) but I can also change the Programs menu for every account simultaneously by doing so.
I thought it was clever anyway.
Last edited by rsw (2009-10-02 22:37:21)
Offline
I'm sure someone else has already thought of this, but I didn't see it mentioned. You can use the 'places' pipe menu to simplify menu.xml and system administration.
I made a directory in /usr/ called "launchers" and to it I added a bunch of shortcuts to the programs I wanted. Then I put:
<menu execute="obpipemenu-places /usr/launchers" id="launch" label="Programs"/>into the menu.xml of each user. Now not only can I edit the menu quickly and easily with my file manager (by drag-and-drop or with symlinks by cli) but I can also change the Programs menu for every account simultaneously by doing so.
I thought it was clever anyway.
good idea
another way would be to use the .desktop files in /usr/share/applications to generate a menu, then it would be auto updating
- - - - - - - - Wiki Pages - - - - - - -
#! install guide *autostart programs, modify the menu & keybindings
configuring Conky *installing scripts
Offline
obdate.sh
displays time and date
DateTime=$(date '+Time: %H:%M ')
DateDate=$(date '+Date: (%a) %d/%m ')
echo "<openbox_pipe_menu>"
echo "<item label=\"$DateTime\"/>"
echo "<item label=\"$DateDate\"/>"
echo "</openbox_pipe_menu>"
this one took a bit to figure out... damn \"/
obbattery.sh
Battery=$(acpi -b | grep "Battery" | sed -nr '/Battery/s/.*(\<[[:digit:]]+%).*/\1/p')
Thermal=$(acpi -t | grep "Thermal" | sed -nr "s/.*(\<[[:digit:]]+\.[[:digit:]]) degrees.*/\1°C/p" )
echo "<openbox_pipe_menu>"
echo "<item label=\"Batt: $Battery\"/>"
echo "<item label=\"Temp: $Thermal\"/>"echo "</openbox_pipe_menu>"
Hope they are usefulllllll
Offline
just done ones for getting tv listings from the radio times, basically a screenscraper so will only work for uk residents and isnt very portable. displays current programme and next.
theres also a '-t' flag so you can print out in without any xml
#! /usr/bin/env python
#
# Author: Ben Holroyd <holroyd.ben@gmail.com>
# License: GPL 3.0+
#
# Usage:
# Put an entry in ~/.config/openbox/menu.xml:
# <menu id="Listing" label="listing" execute="~/.config/openbox/scripts/tvlisting" />
#
from urllib import FancyURLopener
#channels we want to show
channellist = ['BBC1','BBC2','ITV1 London','Channel 4','Five']
address = "http://www.radiotimes.com/ListingsServlet?event=13&broadcastType=1&jspGridLocation=/jsp/tv_listings_grid.jsp&jspListLocation=/jsp/tv_listings_single.jsp&jspError=/jsp/error.jsp&listingsFormat=G"
s = FancyURLopener().open(address).read()
dict={}
def filldict (index):
if index == -1: return
def parse (index):#get title,time and channel from string and return
desc = s[s.find("onMouseOver",index) : s.find("onmouseout",index)]
desc = desc[desc.find("'")+1 : desc.rfind("'", 0, desc.rfind(","))]
desc = desc.split('<br />')
return [a.strip().strip('<b>').strip('</b>').replace("\\'","'") for a in desc]
#get current program
t,prog1,channel,time1= parse(index)
#and next
t,prog2,c,time2=parse(s.find("onMouseOver",s.find("onmouseout",index)))
#load info into a dictionary
dict[channel]=[prog1, time1, prog2, time2]
filldict(s.find('<div class="gridChannel">', index+1))
def showmenu(channel,list):
print " <menu id=\"%s\" label=\"%s\">"%(channel,channel)
print " <item label=\"Now: %s %s\"/>" % (list[0],list[1])
print " <item label=\"Next: %s %s\"/>" % (list[2],list[3])
print " </menu>"
filldict(s.find('<div class="gridChannel">'))
import sys
if len(sys.argv) > 1 and sys.argv[1] == '-t':#just so you can print out plain text if you want
for entries in channellist:
print entries +':\t'+dict[entries][0]+' '+dict[entries][1],
print ' Then: '+dict[entries][2]+' '+dict[entries][3]
sys.exit(0)
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
print "<openbox_pipe_menu>"
for entry in channellist: showmenu(entry,dict[entry])
print "</openbox_pipe_menu>"- - - - - - - - Wiki Pages - - - - - - -
#! install guide *autostart programs, modify the menu & keybindings
configuring Conky *installing scripts
Offline
ok i dont quite have the bandwidth to download the webpages for the above tvlistings script on demand so ive modified it to download the pages for a day and cache them
heres the new one
http://crunchbanglinux.org/pastebin/378
the -p and -t flags remain the same although they now show all programmes for the rest of the day,
to add channels
go to
http://www.radiotimes.com/ListingsServl … hannels=92
select the channel you want, and look at the address, for '&channels=xx'
some where near the end, thats the channel code you want, (you can also look through the page source for them)
then add that code and channel name to channellistdict (line 20) and the name to channellist (line 22)
here are the first few to get you started
BBC1=92, BBC2=105, ITV1 London=26, Channel 4=132, Five=134, BBC3=45,
BBC4=47, Dave=2050, E4=158, Film4=160, Fiver=2062, Five USA=2008, Gold=288, ITV2=185, ITV3=1859, ITV4=1961, More4=1959, Sky1=248, Sky3=1963, Sky Sports 1=262, Watch=2115, Virgin 1=2049
Last edited by benj1 (2009-11-03 10:10:09)
- - - - - - - - Wiki Pages - - - - - - -
#! install guide *autostart programs, modify the menu & keybindings
configuring Conky *installing scripts
Offline
Openbox process menu:
Note: ** Please read before posting **
BTW if you wish to contact me, send me an e-mail instead of a PM.
Offline
This is my contribution. A menu to connect to servers using Filezilla:
#!/bin/sh
obm_item() {
echo " <item label=\"$2\">"
echo " <action name=\"Execute\"><execute>$1</execute></action>"
echo " </item>"
}
echo '<?xml version="1.0" encoding="utf-8"?>'
echo '<openbox_pipe_menu>'
if [ -f ~/.filezilla/sitemanager.xml ]; then
grep Name ~/.filezilla/sitemanager.xml | sed 's| *</\?Name> *||g' | while read i; do
obm_item "filezilla -c 0/$i" "$i"
done
echo "<separator/>"
fi
obm_item "filezilla -s" "$(gettext -d filezilla 'Site Manager')"
echo '</openbox_pipe_menu>'Offline
Here's one I just completed for checking battery status:
And, here's another one I just completed based on mrpeachy's conky Here:
The Title line of each topic opens the first post of the thread and the 'Last Post' line opens the last post. 
Updated the Active Forum topics pipemenu:
obpipecbf.sh V1.1
Now you have the option of choosing how many topic titles you want to show, just change the number for 'maxthreads'. The more topics you have though, the longer it will take to open the menu. Also, I now have it cleaning up the temp file that is created when opening the pipe menu. Still a work in progress...
EDIT: Added second pipe menu.
EDIT: Added new version.
Last edited by jpope (2010-01-20 05:19:20)
--
...old school #! user now running Arch
jpope.org
Offline
The Title line of each topic opens the first post of the thread and the 'Last Post' line opens the last post.
very nice! i was thinking how cool it would be if conky allowed clickable links, but it doesnt, so here is the solution 
Offline
Another one. This will list all your backup profiles in grsync.
#!/usr/bin/env bash
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
print_item() {
echo " <item label=\"$2\"><action name=\"Execute\"><execute>$1</execute></action></item>"
}
echo '<?xml version="1.0" encoding="utf-8"?>'
echo '<openbox_pipe_menu>'
print_item 'grsync' 'Edit backup profiles'
if [ -f ~/.grsync/grsync.ini ]; then
echo '<separator/>'
grep '^\[[^_].*\]$' .grsync/grsync.ini | sed -e's/^\[//g' -e's/\]$//g' | while read profile; do
print_item "grsync -e -s '$profile'" "$profile"
done
fi
echo '</openbox_pipe_menu>'Offline
Bash "places" openbox pipe menu:
Note: ** Please read before posting **
BTW if you wish to contact me, send me an e-mail instead of a PM.
Offline
hi #!ers 
i thought we can use conky-cli to display some info in pipe-menu.. something like that:
with this code : ibmtemps.sh
#!/bin/sh
HDD=$(/usr/local/bin/conky-cli -q -i 1 -t '${ibm_temps 2}')
CPU=$(/usr/local/bin/conky-cli -q -i 1 -t '${ibm_temps 0}')
GPU=$(/usr/local/bin/conky-cli -q -i 1 -t '${ibm_temps 3}')
echo "<openbox_pipe_menu>"
echo "<item label=\"hard drive:$HDD\"/>"
echo "<item label=\"processor:$CPU\"/>"
echo "<item label=\"graphic card:$GPU\"/>"
echo "</openbox_pipe_menu>"so, in fact, you can display many infos by this way 
Offline
Wow, nice way to go menu-happy 
Offline
MoC pipemenu:
Note: ** Please read before posting **
BTW if you wish to contact me, send me an e-mail instead of a PM.
Offline
hi #!ers
i thought we can use conky-cli to display some info in pipe-menu.. something like that:with this code : ibmtemps.sh
#!/bin/sh HDD=$(/usr/local/bin/conky-cli -q -i 1 -t '${ibm_temps 2}') CPU=$(/usr/local/bin/conky-cli -q -i 1 -t '${ibm_temps 0}') GPU=$(/usr/local/bin/conky-cli -q -i 1 -t '${ibm_temps 3}') echo "<openbox_pipe_menu>" echo "<item label=\"hard drive:$HDD\"/>" echo "<item label=\"processor:$CPU\"/>" echo "<item label=\"graphic card:$GPU\"/>" echo "</openbox_pipe_menu>"so, in fact, you can display many infos by this way
ARP!!!!!!!!! You sly dog you! Now that's great!
This I play with!! 
Thank you!
#! Etiquette | Conky PitStop | VSIDO | Interactive LUA
Weather v9000 | Teo x4 Sites | Arclance | Finnish
Offline
MoC pipemenu:
Thanks for the link --- another to look into!
#! Etiquette | Conky PitStop | VSIDO | Interactive LUA
Weather v9000 | Teo x4 Sites | Arclance | Finnish
Offline
Thanks for the link --- another to look into!
I was so glad when I found it. Makes MoC even better!
Offline
My first pipemenu: a (recursive) directory listing by time modified. Much like the included place menu, except it list files from newest to oldest rather than alphabetical order. Should descend into sub-directories and do the same (I've had a unknown hits and misses with this). It cuts off long file names after 20 characters, but this is easily changed.
I use it to call up recently added media in vlc. At the beginning of the script, you'll want to tell it what program you'd like to open the files with (the VIDPRG variable.)
It takes the directory you want to lookup as its one command line option. (e.g. pypipe.py /media/tv ).
I'm just beginning to learn python, so it is written in that. Comments appreciated.
You can check it out here: http://crunchbanglinux.org/pastebin/1123
In the future:
use default program to open based on file type (no clue on this really. Could use extension-lists and different program names as a workaround)
add a "browse..." to the top of each menu/submenu
Last edited by jmbarnes (2011-07-14 17:40:33)
IRC: PizzaAndWine Script bits: Incremental Backup | Sleep Timer
Offline
use default program to open based on file type (no clue on this really. Could use extension-lists and different program names as a workaround)
You could try exo-open (for Xfce) or xdg-open for opening files based on mimetype.
Note: ** Please read before posting **
BTW if you wish to contact me, send me an e-mail instead of a PM.
Offline
You could try exo-open (for Xfce) or xdg-open for opening files based on mimetype.
As always Anonymous comes through. This works perfectly.
Now includes:
Uses xdg-open to open program based on user defaults. (Exo-open also available in script)
White-space handling is better (i.e. there is whitespace handling at all now.)
Each directory has a "Browse here..." at top
Known bugs:
FIXED: Doesn't handle characters like '&' well because Openbox's XML doesn't much like them.
Updated:http://crunchbanglinux.org/pastebin/1128
Last edited by jmbarnes (2011-07-15 18:20:18)
IRC: PizzaAndWine Script bits: Incremental Backup | Sleep Timer
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.