diff options
Diffstat (limited to '.config/openbox/scripts')
-rwxr-xr-x | .config/openbox/scripts/ob-mpd.py | 233 | ||||
-rwxr-xr-x | .config/openbox/scripts/processes.py | 232 | ||||
-rwxr-xr-x | .config/openbox/scripts/system-info.sh | 112 | ||||
-rwxr-xr-x | .config/openbox/scripts/wallmenu.py | 109 | ||||
-rwxr-xr-x | .config/openbox/scripts/xcompmgr.sh | 94 | ||||
-rwxr-xr-x | .config/openbox/scripts/xdgmenu.php | 207 |
6 files changed, 987 insertions, 0 deletions
diff --git a/.config/openbox/scripts/ob-mpd.py b/.config/openbox/scripts/ob-mpd.py new file mode 100755 index 0000000..0460478 --- /dev/null +++ b/.config/openbox/scripts/ob-mpd.py @@ -0,0 +1,233 @@ +#!/usr/bin/env python +# +# Author: John Eikenberry <jae@zhar.net> +# License: GPL 2.0 +# +# Changelog +# 2007-09-09 - Fixed compatibility issue with mpdclient2 version 1.0 +# vs. 11.1 which I have (debian). +# 2007-11-18 - Added playlist load/clear support. +# +# +# This script depends on py-libmpdclient2 which you can get from +# http://incise.org/index.cgi/py-libmpdclient2 +# +# Usage: +# Put an entry in ~/.config/openbox/menu.xml: +# <menu id="mpd" label="MPD" execute="~/.config/openbox/scripts/ob-mpd.py" /> +# +# Add the following wherever you'd like it to be displayed in your menu: +# <menu id="mpd" /> +# +# +# Originally Based on code by John McKnight <jmcknight@gmail.com> +# +## Main changes from original version: +# +# Changed to use libmpdclient2. +# Refactored/Cleaned up the code. +# Added random/repeat toggle indicators. +# Changed Pause/Play so only the appropriate one would show up. +# Added actions to start and stop mpd daemon. +# Added exception to deal with no id3 tags. +# Added volume controls. +# Added output setting controls. +# Determine location of script dynamically instead of hardcoded + +import os, sys, socket +import mpdclient2 + +argv = sys.argv + +# The default port for MPD is 6600. If for some reason you have MPD +# running on a different port, change this setting. +mpdPort = 6600 + +# determin path to this file +my_path = sys.modules[__name__].__file__ +# if this fails for some reason, just set it manually. +# Eg. +# my_path = "~/.config/openbox/scripts/ob-mpd.py" + + +separator = "<separator />" +info = """<item label="%s" />""" +action = ("""<item label="%s"><action name="Execute">""" + """<execute>MY_PATH %s</execute>""" + """</action></item>""").replace("MY_PATH",my_path) +menu = """<menu id="%s" label="%s">""" +menu_end = """</menu>""" + + +try: + connect = mpdclient2.connect(port=mpdPort) +except socket.error: + # If MPD is not running. + if len(argv) > 1 and argv[1] == 'start': + os.execl('/usr/bin/mpd','$HOME/.mpdconf') + else: + print ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<openbox_pipe_menu>") + print action % ('MPD is not running [start]','start') + print "</openbox_pipe_menu>" + +else: # part of connect try block + + song = connect.currentsong() + stats = connect.stats() + status = connect.status() + + if status['state'] == "stop": + display_state = "Not playing" + else: + try: + display_state = "%s - %s" % (song.artist, song.title) + except (AttributeError, KeyError): # no id3 tags + display_state = os.path.basename(song.file) + if status['state'] == "pause": + display_state += " (paused)" + display_state = display_state.replace('"',"'") + display_state = display_state.replace('&','&') + + if len(argv) > 1: + + state = status.state + def play(): + if state == "stop" or state == "pause": + connect.play() + + def pause(): + if state == "play": + connect.pause(1) + elif state == "pause": + connect.play() + + def stop(): + if state == "play" or state == "pause": + connect.stop() + + def prev(): + if state == "play": + connect.previous() + + def next(): + if state == "play": + connect.next() + + random_state = int(status.random) + def random(): + if random_state: + connect.random(0) + else: + connect.random(1) + + repeat_state = int(status.repeat) + def repeat(): + if repeat_state: + connect.repeat(0) + else: + connect.repeat(1) + + def kill(): + try: + connect.kill() + except EOFError: + pass + + def update(): + connect.update() + + def volume(setto): + relative = (setto[0] in ['+','-']) + setto = int(setto) + if relative: + newvol = int(status.volume) + setto + newvol = newvol <= 100 or 100 + newvol = newvol >= 0 or 0 + connect.setvol(setto) + + def client(): + os.execlp('x-terminal-emulator','-e','ncmpc') + + def enable(output_id): + connect.enableoutput(int(output_id)) + + def disable(output_id): + connect.disableoutput(int(output_id)) + + def load(list_name): + connect.load(list_name) + + def clear(): + connect.clear() + + if (argv[1] == "play"): play() + elif (argv[1] == "pause"): pause() + elif (argv[1] == "stop"): stop() + elif (argv[1][:4] == "prev"): prev() + elif (argv[1] == "next"): next() + elif (argv[1] == "random"): random() + elif (argv[1] == "repeat"): repeat() + elif (argv[1] == "volume"): volume(argv[2]) + elif (argv[1] == "client"): client() + elif (argv[1] == "kill"): kill() + elif (argv[1] == "update"): update() + elif (argv[1] == "enable"): enable(argv[2]) + elif (argv[1] == "disable"): disable(argv[2]) + elif (argv[1] == "load"): load(argv[2]) + elif (argv[1] == "clear"): clear() + + else: + # + print """<?xml version="1.0" encoding="UTF-8"?>""" + print """<openbox_pipe_menu>""" + print action % (display_state,'client') + print separator + print action % ('Next','next') + print action % ('Previous','prev') + if status['state'] in ["pause","stop"]: + print action % ('Play','play') + if status['state'] == "play": + print action % ('Pause','pause') + print action % ('Stop','stop') + print separator + print menu % ("volume","Volume: %s%%" % status.volume) + print action % ('[100%]','volume 100') + print action % (' [80%]','volume 80') + print action % (' [60%]','volume 60') + print action % (' [40%]','volume 40') + print action % (' [20%]','volume 20') + print action % ('[Mute]','volume 0') + print menu_end + print menu % ("playlist","Playlist") + print action % ('clear','clear') + print separator + for entity in connect.lsinfo(): + if 'playlist' in entity: + playlist = entity['playlist'].replace('&', '&') + print action % (playlist, 'load "%s"' % playlist) + print menu_end + print menu % ("output","Audio Output") + for out in connect.outputs(): + name,oid = out['outputname'],out['outputid'] + on = int(out['outputenabled']) + print action % ("%s [%s]" % (name, on and 'enabled' or 'disabled'), + "%s %s" % ((on and 'disable' or 'enable'), oid)) + print menu_end + print separator + print action % ('Toggle random %s' % ( + int(status.random) and '[On]' or '[Off]'), 'random') + print action % ('Toggle repeat %s' % ( + int(status.repeat) and '[On]' or '[Off]'), 'repeat') + print separator + print action % ('Update Database','update') + print action % ('Kill MPD','kill') + print "</openbox_pipe_menu>" + +# print menu % ("Song Info","Volume: %s%%" % status.volume) +# print info % ('%s kbs' % status.bitrate) +# print separator +# print info % ("Artists in DB: %s" % stats.artists) +# print info % ("Albums in DB: %s" % stats.albums) +# print info % ("Songs in DB: %s" % stats.songs) + diff --git a/.config/openbox/scripts/processes.py b/.config/openbox/scripts/processes.py new file mode 100755 index 0000000..ac475bb --- /dev/null +++ b/.config/openbox/scripts/processes.py @@ -0,0 +1,232 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +""" +#------------------------------------------------------------------------------- + +processes.py - version 7 +by Vlad George + +#------------------------------------------------------------------------------- + +Description: + This script pipes a process manipulation menu into the openbox menu. + +Usage: + Just place this script in ~/.config/openbox/scripts, make it executable; if you want you can enlist the processes + which should not be shown in the unwanted_procs list below, then add following to your ~/.config/openbox/menu.xml: + "<menu id="proc-menu" label="processes" execute="~/.config/openbox/scripts/processes.py" />... + <menu id="root-menu" label="Openbox3">...<menu id="proc-menu" />...</menu>" + and reconfigure openbox. + To enable cpu usage display uncomment the lines marked with (***) (lines 106-108 and 146). + Note: You need 'ps'. + To enable cpulimit just uncomment the lines marked with (#*#) (lines 158-169). + Note: You need 'cpulimit'. Get it from here: "http://cpulimit.sourceforge.net" + +Changelog: + 20.02.07: 7th version - added "-z" flag to cpulimit; added ValueError handling for printXml; added --title flag + 04.12.07: 6th version - added cpulimit; to enable it just uncomment the lines marked with (#*#) + 18.11.07: 5th version - processes alphabetically sorted + 22.10.07: 4th version - totally removed SleepAVG from script. for kernels < 2.6.20 please use earlier versions. + simplified cpu usage command. + 07.07.07: 3rd version - added cpu usage; + since SleepAVG was removed from /proc (2.6.20), it will be only displayed depending on running kernel version + 17.02.07: 2nd version - shortened procData + +#------------------------------------------------------------------------------- + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +http://www.fsf.org/ + +""" + +#------------------------------------------------------------------------------- +# User set variables +#------------------------------------------------------------------------------- + +## processes (e.g. daemons, bash, this script, etc) you do not want to be shown in the process manipulation menu: +## !!! don´t forget quotes !!! + +## unwanted_procs = ["processes.py","ssh-agent","gconfd-2","dbus-daemon","dbus-launch","kded","dcopserver","..."] +unwanted_procs = ["processes.py","sh","bash","netstat","ssh-agent","gconfd-2","gnome-pty-helpe","dbus-daemon","dbus-launch",\ + "visibility","pypanel","knotify","kdeinit","klauncher","kded","dcopserver","kio_file"] + +## if you want a title (separator) for the processes menu you can set it here; to show the title use the "--title" flag (/path/to/processes.py --title) +processes_menu_title = "processes" + + +#------------------------------------------------------------------------------- +# Script +#------------------------------------------------------------------------------- + + +def _procName(pid): + """ pid -> processname """ + try: + return file(os.path.join('/proc', str(pid), 'status'), 'r').readline().split()[1] + except IOError: + return None + + +def _procData(pid): + """ pid -> info_list = [State, VmSize, VmLck, VmRSS, VmLib, priority(nice), command, cpu usage] """ + info_list = list() + + ## from /proc/<pid>/status get State, VmSize, VmLck, VmRSS, VmLib + status_file = file(os.path.join("/proc", str(pid), "status"), 'r') + status = status_file.readlines() + status_file.close() + [info_list.append(status[i].split(":")[1].lstrip().rstrip("\n")) for i in (1,11,12,14,18)] + + ## from /proc/<pid>/stat get priority(nicelevel) + priority_file = file(os.path.join('/proc', str(pid), 'stat'), 'r') + priority = priority_file.read() + priority_file.close() + info_list.append(priority.split()[18]) + + ## from /proc/<pid>/cmdline get command + cmdline_file = file(os.path.join("/proc", str(pid),"cmdline"),'r') + cmdline = cmdline_file.read() + cmdline_file.close() + info_list.append(" ".join(cmdline.split("\x00")[:-1])) + + ## from "ps --pid %s -o pcpu=" get cpu usage for pid + ## (***) comment out following three lines to disable cpu usage display + #ps_cpu_for_pid = 'ps --pid %s -o pcpu=' % (pid) + #ps_cmd = os.popen(ps_cpu_for_pid).readline() + #info_list.append(ps_cmd) + ## (***) + return info_list + + +def userPidFilter(): + """ fiters pids from /proc/<pid>/ for user who owns script excluding the unwanted_procs ids """ + uid = os.stat(sys.argv[0])[4] + uid_pids = list() + for pid in os.listdir("/proc"): + if os.path.isdir(os.path.join("/proc", pid)): + try: + if os.stat(os.path.join("/proc", pid))[4] == uid : + uid_pids.append(int(pid)) + except ValueError: + pass + + ## sort pids according to process names + pid_proc_list = list() + [pid_proc_list.append((i, _procName(i))) for i in uid_pids] + + def removeProcsFromList(pid): + process = _procName(pid) + if process in unwanted_procs: + pid_proc_list.remove((pid, process)) + map(removeProcsFromList, uid_pids) + + pid_proc_list.sort(key = lambda t:t[1].lower()) + return [pid_proc_list[i][0] for i in xrange(len(pid_proc_list))] + + +def printXml(pid): + """ xml output for each pid + _procData(pid)=[[0]-State, [1]-VmSize, [2]-VmLck, [3]-VmRSS, [4]-VmLib, [5]-priority(nice), [6]-command, [(***)optional: [7]-cpu usage]] """ + + proc_info = _procData(pid) + +## (***) uncomment following line to enable cpu usage display: + #print '<item label="cpu usage: %s' % (proc_info[7]) + ' %"><action name="execute"><command>true</command></action></item>' +## (***) + print '<menu id="%s-menu-memory" label="memory: %s MB">' % (pid, int(proc_info[1].split()[0])/1024) + print '<item label="Ram: %s"><action name="Execute"><command>true</command></action></item>' % (proc_info[3]) + print '<item label="Lib: %s"><action name="Execute"><command>true</command></action></item>' % (proc_info[4]) + print '<item label="Lock: %s"><action name="Execute"><command>true</command></action></item>' % (proc_info[2]) + print '<item label="Total: %s"><action name="Execute"><command>true</command></action></item>' % (proc_info[1]) + print '</menu>' + + print '<separator />' + +## (#*#) uncomment following lines to enable cpulimit: + #print '<menu id="%s-menu-cpulimit" label="cpulimit">' % (pid) + #print '<item label=" 10 %"><action name="Execute"><command>cpulimit -p %s -z -l 10</command></action></item>' % (pid) + #print '<item label=" 20 %"><action name="Execute"><command>cpulimit -p %s -z -l 20</command></action></item>' % (pid) + #print '<item label=" 30 %"><action name="Execute"><command>cpulimit -p %s -z -l 30</command></action></item>' % (pid) + #print '<item label=" 40 %"><action name="Execute"><command>cpulimit -p %s -z -l 40</command></action></item>' % (pid) + #print '<item label=" 50 %"><action name="Execute"><command>cpulimit -p %s -z -l 50</command></action></item>' % (pid) + #print '<item label=" 60 %"><action name="Execute"><command>cpulimit -p %s -z -l 60</command></action></item>' % (pid) + #print '<item label=" 70 %"><action name="Execute"><command>cpulimit -p %s -z -l 70</command></action></item>' % (pid) + #print '<item label=" 80 %"><action name="Execute"><command>cpulimit -p %s -z -l 80</command></action></item>' % (pid) + #print '<item label=" 90 %"><action name="Execute"><command>cpulimit -p %s -z -l 90</command></action></item>' % (pid) + #print '<item label="100 %"><action name="Execute"><command>cpulimit -p %s -z -l 100</command></action></item>' % (pid) + #print '</menu>' +## (#*#) + + print '<menu id="%s-menu-priority" label="priority (%s)">' % (pid, proc_info[5]) + print '<item label="-10 (fast)"><action name="Execute"><command>renice -10 %s</command></action></item>' % (pid) + print '<item label="-5"><action name="Execute"><command>renice -5 %s</command></action></item>' % (pid) + print '<item label="0 (base)"><action name="Execute"><command>renice 0 %s</command></action></item>' % (pid) + print '<item label="5"><action name="Execute"><command>renice 5 %s</command></action></item>' % (pid) + print '<item label="10"><action name="Execute"><command>renice 10 %s</command></action></item>' % (pid) + print '<item label="15"><action name="Execute"><command>renice 15 %s</command></action></item>' % (pid) + print '<item label="19 (idle)"><action name="Execute"><command>renice 19 %s</command></action></item>' % (pid) + print '</menu>' + + print '<menu id="%s-menu-state" label="%s">' % (pid, proc_info[0]) + print '<item label="stop"><action name="Execute"><command>kill -SIGSTOP %s</command></action></item>' % (pid) + print '<item label="continue"><action name="Execute"><command>kill -SIGCONT %s</command></action></item>' % (pid) + print '</menu>' + + print '<menu id="%s-menu-stop" label="stop signals">' % (pid) + print '<item label="exit"><action name="Execute"><command>kill -TERM %s</command></action></item>' % (pid) + print '<item label="hangup"><action name="Execute"><command>kill -HUP %s</command></action></item>' % (pid) + print '<item label="interrupt"><action name="Execute"><command>kill -INT %s</command></action></item>' % (pid) + print '<item label="kill"><action name="Execute"><command>kill -KILL %s</command></action></item>' % (pid) + print '</menu>' + print '<separator />' + + print '<menu id="%s-menu-command" label="command">' % (pid) + print '<item label="%s"><action name="Execute"><command>true</command></action></item>' % (proc_info[6]) + print '<separator />' + print '<item label="spawn new"><action name="Execute"><command>%s</command></action></item>' % (proc_info[6]) + print '</menu>' + + +def generateMenu(pid): + """ generate main menu """ + print '<menu id="%s-menu" label="%s" execute="%s --pid %s"/>' % (pid, _procName(pid), sys.argv[0], pid) + +#------------------------------------------------------------------------------- +# Main +#------------------------------------------------------------------------------- + +import os, sys + +#-------------------------# +if __name__ == "__main__" : +#-------------------------# + print '<?xml version="1.0" encoding="UTF-8"?>' + print '<openbox_pipe_menu>' + args = sys.argv[1:] + if ('--pid' in args): + try: + printXml(int(sys.argv[2])) + except ValueError and IOError: + pass + else: + if ('--title' in args): + print '<separator label="%s" />' % (processes_menu_title) + else: + pass + map(generateMenu, userPidFilter()) + print '</openbox_pipe_menu>' + +# vim: set ft=python nu ts=4 sw=4 : + diff --git a/.config/openbox/scripts/system-info.sh b/.config/openbox/scripts/system-info.sh new file mode 100755 index 0000000..c104288 --- /dev/null +++ b/.config/openbox/scripts/system-info.sh @@ -0,0 +1,112 @@ +#!/bin/bash +######## This is a script made +######## by 'yettenet'. +######## +######## SysInfo script for OpenBox +######## v0.1 +######## +######## The author does not take +######## any responsibility for +######## what it might do to your +######## computer, though it's +######## improbable to do any harm. +######## +######## You may share the script with +######## everyone and modify it for your +######## liking, as long as you +######## GIVE CREDIT. +######## +######## To add it to Openbox, copy it to +######## your Openbox/scripts folder, which usually is at +######## ~/.config/openbox/scripts +######## +######## edit your menu.xml file, which usually is at +######## ~/.config/openbox/menu.xml +######## and add the following line (in case you have the usual paths - if not, edit the path as needed): +######## +########<menu execute="~/.config/openbox/scripts/sysinfo_v01-by_yettenet.script" id="sysinfo-menu" label="SysInfo"/> +######## +######## Below you will find the settings +######## (the script still needs to be tested) + +######## settings + +MountPoint1=$(echo /dev/root) +MountPoint2=$(echo /dev/trekstor1) +MountPoint3=$(echo /dev/trekstor2) +MountPoint4=$(echo /dev/sda3) +MountPoint5=$(echo /media/crossfire) +#NetworkDevice1=$(echo eth0) +#NetworkDevice2=$(echo eth1) #Uncomment some lines to make it work! + +######## /settings + + +Signal=$(cat /sys/class/net/wlan0/wireless/link) +User=$(whoami) +Host=$(uname -n) +System=$(uname -s) +Release=$(uname -r) +Arch=$(uname -m) + +SizeMountPoint1=$(df | grep "$MountPoint1" | cut -c1-20,51-55) +SizeMountPoint2=$(df | grep "$MountPoint2" | cut -c1-20,51-55) +SizeMountPoint3=$(df | grep "$MountPoint3" | cut -c1-20,51-55) +SizeMountPoint4=$(df | grep "$MountPoint4" | cut -c1-20,51-55) +SizeMountPoint5=$(df | grep "$MountPoint5" | cut -c1-20,51-55) + +#NetDev1ip=$(/sbin/ifconfig "$NetworkDevice1" | grep "inet addr:" | sed "s/.*inet addr://" | sed "s/Bcast.*//") +#NetDev1down=$(/sbin/ifconfig "$NetworkDevice1" | grep bytes | sed 's/.*RX bytes:[0-9]* (//' | sed 's/iB).*TX.*//' | sed 's/b).*TX.*//' | sed 's/).*TX.*//') +#NetDev1up=$(/sbin/ifconfig "$NetworkDevice1" | grep bytes | sed 's/.*TX bytes:[0-9]* (//' | sed 's/iB)//' |sed 's/b).*//' | sed 's/).*//') + +#NetDev2ip=$(/sbin/ifconfig "$NetworkDevice1" | grep "inet addr:" | sed "s/.*inet addr://" | sed "s/Bcast.*//") +#NetDev2down=$(/sbin/ifconfig "$NetworkDevice1" | grep bytes | sed 's/.*RX bytes:[0-9]* (//' | sed 's/iB).*TX.*//' | sed 's/b).*TX.*//' | sed 's/).*TX.*//') +#NetDev2up=$(/sbin/ifconfig "$NetworkDevice1" | grep bytes | sed 's/.*TX bytes:[0-9]* (//' | sed 's/iB)//' |sed 's/b).*//' | sed 's/).*//') + +DateDate=$(date '+Date: %m.%d.%Y (%a)') +DateWeek=$(date '+Week: %W') + DateDay=$(date '+ Day: %j') +DateTime=$(date '+Time: %I:%M [%Z]') +UpTime=$(uptime | sed 's/.* up //' | sed 's/[0-9]* us.*//' | sed 's/ day, /d/' | sed 's/ days, /d /' | sed 's/:/h /' | sed 's/ min//'| sed 's/,/m/' | sed 's/ / /') + +MemTotal=$(echo "scale = 2; ("$(cat /proc/meminfo | grep MemTotal: | awk '{print $2}' | sed 's/k//')" /1024)" | bc) + MemFree=$(echo "scale = 2; ("$(cat /proc/meminfo | grep MemFree: | awk '{print $2}' | sed 's/k//')" /1024) + ("$(cat /proc/meminfo | grep grep -m 1 Cached: | awk '{print $2}' | sed 's/k//')" /1024)" | bc) + MemUsed=$(echo "scale = 2; ("$(cat /proc/meminfo | grep MemTotal: | awk '{print $2}' | sed 's/k//')" /1024) - (("$(cat /proc/meminfo | grep MemFree: | awk '{print $2}' | sed 's/k//')" /1024) + ("$(cat /proc/meminfo | grep -m 1 Cached: | awk '{print $2}' | sed 's/k//')" /1024))" | bc) + +SwpTotal=$(echo "scale = 2; ("$(cat /proc/meminfo | grep SwapTotal: | awk '{print $2}' | sed 's/k//')" /1024)" | bc) + SwpFree=$(echo "scale = 2; ("$(cat /proc/meminfo | grep SwapFree: | awk '{print $2}' | sed 's/k//')" /1024)" | bc) + SwpUsed=$(echo "scale = 2; ("$(cat /proc/meminfo | grep SwapTotal: | awk '{print $2}' | sed 's/k//')" /1024) - ("$(cat /proc/meminfo | grep SwapFree: | awk '{print $2}' | sed 's/k//')" /1024)" | bc) + +MemUsedPercent=$(echo "scale = 2; (("$(cat /proc/meminfo | grep MemTotal: | awk '{print $2}' | sed 's/k//')" /1024) - (("$(cat /proc/meminfo | grep MemFree: | awk '{print $2}' | sed 's/k//')" /1024) + ("$(cat /proc/meminfo | grep -m 1 Cached: | awk '{print $2}' | sed 's/k//')" /1024))) / ("$(cat /proc/meminfo | grep MemTotal: | awk '{print $2}' | sed 's/k//')" /1024) *100" | bc) +SwpUsedPercent=$(echo "scale = 2; (("$(cat /proc/meminfo | grep SwapTotal: | awk '{print $2}' | sed 's/k//')" /1024) - ("$(cat /proc/meminfo | grep SwapFree: | awk '{print $2}' | sed 's/k//')" /1024)) / ("$(cat /proc/meminfo | grep SwapTotal: | awk '{print $2}' | sed 's/k//')" /1024) *100" | bc) + +CPUmodel=$(cat /proc/cpuinfo | grep "model name" | sed 's/.*: //') +CPUfreq=$(cat /proc/cpuinfo | grep -m 1 "cpu MHz" | sed 's/.*: //' | cut -c1-4) +CPUcache=$(cat /proc/cpuinfo | grep -m 1 "cache size" | sed 's/.*: //') + + +echo "<openbox_pipe_menu>" +echo "<separator label = \"Mountpoint ~ Space Used\"/>" +test "$SizeMountPoint1" && echo "<item label=\"$SizeMountPoint1\"/>" +test "$SizeMountPoint2" && echo "<item label=\"$SizeMountPoint2\"/>" +test "$SizeMountPoint3" && echo "<item label=\"$SizeMountPoint3\"/>" +test "$SizeMountPoint4" && echo "<item label=\"$SizeMountPoint4\"/>" +test "$SizeMountPoint5" && echo "<item label=\"$SizeMountPoint5\"/>" + +echo "<separator label=\"Hardware ~ Use\"/>" +echo "<item label=\"RAM used: $MemUsedPercent%\"/>" +echo "<item label=\"Swap used: $SwpUsedPercent%\"/>" +echo "<item label=\"Cpu-Freq: $CPUfreq MHz\"/>" +echo "<item label=\"Signal: $Signal%\"/>" + +#echo "<separator label = \"Network ~ "$NetworkDevice2" \"/>" +#echo "<item label=\""$NetworkDevice1" ~ ip: $NetDev2ip\"/>" +#echo "<item label=\""$NetworkDevice1" ~ downloaded: "$NetDev2down"iB\"/>" +#echo "<item label=\""$NetworkDevice1" ~ uploaded: "$NetDev2up"iB\"/>" + +echo "<separator label = \"Date ~ Time\"/>" +echo "<item label=\"$DateDate\"/>" +echo "<item label=\"$DateTime\"/>" +echo "<item label=\"Uptime: $UpTime\"/>" + +echo "</openbox_pipe_menu>" diff --git a/.config/openbox/scripts/wallmenu.py b/.config/openbox/scripts/wallmenu.py new file mode 100755 index 0000000..492c91f --- /dev/null +++ b/.config/openbox/scripts/wallmenu.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python + +import os +import re +import string +import sys +from os.path import isdir + + +# --------------------------------------------------------------------------- # +# wallmenu.py # +# version 0.3.0 # +# --------------------------------------------------------------------------- # +# This script creates an openbox pipe menu to choose a wallpaper. +# You can configure what types of files are allowed, where to search for +# wallpapers, and what program to use to set the wallpaper. +# This script will also update a configuration file +# (~/.config/openbox/wallmenurc) that stores the last set wallpaper. +# This means that you can add a line to your .xinitrc file to load the +# last set wallpaper on start-up. +# You can configure this script with the variables below. +# This script will recursively go through directories from the one you +# specify, searching for image files. +# --------------------------------------------------------------------------- # + +# --------------------------------------------------------------------------- # +# Using the config file # +# --------------------------------------------------------------------------- # +# To use the config file that stores the filename of the last set wallpaper, +# you can add a line to your .xinitrc file to load it on start-up. If you +# use Esetroot you can use this example, if not just replace the program +# command with your chosen program: +# +# Esetroot `cat ~/.config/openbox/wallmenurc` +# +# If you want to use this script with feh to set your wallpaper, you don't +# need the script to update a config file. feh automatically inserts the full +# command string used to set the wallpaper into ~/.fehbg. In order to set the +# wallpaper back at the next startof openbox, just add the following to +# ~/.xinitrc: +# +# eval `cat ~/.fehbg` +# --------------------------------------------------------------------------- # + +# --------------------------------------------------------------------------- # +# User configuration # +# --------------------------------------------------------------------------- # +# types of files accepted (list, seperated by a |) +filetypes = "jpg|png|gif" +# directory where wallpapers are stored (must be long: no ~ symbol allowed) +directory = "/home/ben/.wallpapers" +# program to set wallpaper +program = "feh --bg-scale" +# store wallpaper name in a config file? +config = "no" +# --------------------------------------------------------------------------- # + +def genmenu(start, directory): + # get a directory list + dirlist = os.listdir(directory) + for d in dirlist: + # set di to overall directory + di = directory + "/" + d + # if we get a dir, generate a menu + if isdir(di): + print "" + print " <menu id=\"" + di + "\" label=\"" + d + "\" >" + genmenu(start, di) + print " </menu>" + # if we get a file, check if it is a valid type + else: + if re.search(filetypes, string.lower(di)) > 0: + # make fi variable just filename, without extension + fi = string.replace(string.replace(di, directory, ""), "/", "") + fi = fi[:string.rfind(fi, ".")] + # if so, add it to the pipe menu + print " <item label=\"" + fi + "\">" + # execute line to set wallpaper + print " <action name=\"Execute\"><execute>" + program + " \"" + di + "\"</execute></action>" + # if we want to update config file, do so + if config == "yes": + print " <action name=\"Execute\"><execute>~/.config/openbox/wallmenu.py " + di + "</execute></action>" + print " </item>" + + +def main(argv): + + # if we've been passed an argument update the config file with the arg + if len(argv) == 1: + os.system("echo " + argv[0] + " > ~/.config/openbox/wallmenurc") + + else: + + # start menu + print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + print "<openbox_pipe_menu>" + print " <separator label=\"Wallpaper\" />" + + # set the original start directory + start = directory + # generate menu + genmenu(start, directory) + + # end menu + print "</openbox_pipe_menu>" + +# run the main() function +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/.config/openbox/scripts/xcompmgr.sh b/.config/openbox/scripts/xcompmgr.sh new file mode 100755 index 0000000..f19dcc2 --- /dev/null +++ b/.config/openbox/scripts/xcompmgr.sh @@ -0,0 +1,94 @@ +#!/bin/bash +# Openbox Pipe Menu for xcompmgr +# Written for CrunchBang Linux <http://crunchbang.org/projects/linux/> +# by Philip Newborough (aka corenominal) <mail@philipnewborough.co.uk> + +# Set xcompmgr command options +#EXEC='xcompmgr -c -t-5 -l-5 -r4.2 -o.55' #basic +EXEC='xcompmgr -cCfF -t-5 -l-5 -r4.2 -o.55 -D6' #more effects + +# Toggle compositing. Call with "myxcompmgr --startstop" +if [ "$1" = "--startstop" ]; then + if [ ! "$(pidof xcompmgr)" ]; then + $EXEC + else + killall xcompmgr + fi + exit 0 +fi +# Output Openbox menu +if [ ! "$(pidof xcompmgr)" ]; then + cat << _EOF_ + <openbox_pipe_menu> + <separator label="Compositing" /> + <item label="Enable Compositing"> + <action name="Execute"> + <execute>~/.config/openbox/scripts/xcompmgr.sh --startstop</execute> + </action> + </item> + </openbox_pipe_menu> +_EOF_ +else + cat << _EOF_ + <openbox_pipe_menu> + <separator label="Compositing" /> + <item label="Remove Transparency from Target Window"> + <action name="Execute"> + <execute>transset-df 1</execute> + </action> + </item> + <item label="Set Target Window Transparency to 10%"> + <action name="Execute"> + <execute>transset-df .90</execute> + </action> + </item> + <item label="Set Target Window Transparency to 20%"> + <action name="Execute"> + <execute>transset-df .80</execute> + </action> + </item> + <item label="Set Target Window Transparency to 30%"> + <action name="Execute"> + <execute>transset-df .70</execute> + </action> + </item> + <item label="Set Target Window Transparency to 40%"> + <action name="Execute"> + <execute>transset-df .60</execute> + </action> + </item> + <item label="Set Target Window Transparency to 50%"> + <action name="Execute"> + <execute>transset-df .50</execute> + </action> + </item> + <item label="Set Target Window Transparency to 60%"> + <action name="Execute"> + <execute>transset-df .40</execute> + </action> + </item> + <item label="Set Target Window Transparency to 70%"> + <action name="Execute"> + <execute>transset-df .30</execute> + </action> + </item> + <item label="Set Target Window Transparency to 80%"> + <action name="Execute"> + <execute>transset-df .20</execute> + </action> + </item> + <item label="Set Target Window Transparency to 90%"> + <action name="Execute"> + <execute>transset-df .10</execute> + </action> + </item> + <separator/> + <item label="Disable Compositing"> + <action name="Execute"> + <execute>~/.config/openbox/scripts/xcompmgr.sh --startstop</execute> + </action> + </item> + </openbox_pipe_menu> +_EOF_ +fi +exit 0 diff --git a/.config/openbox/scripts/xdgmenu.php b/.config/openbox/scripts/xdgmenu.php new file mode 100755 index 0000000..b5ded26 --- /dev/null +++ b/.config/openbox/scripts/xdgmenu.php @@ -0,0 +1,207 @@ +#!/usr/bin/env php +<?php +error_reporting(0); +$dirs = array ( + "/usr/share/applications", +// "/usr/share/control-center-2.0/capplets", +// $_SERVER["HOME"] . "/.gnome2/vfolders/applications" +); + +function parseDesktopFile($path) +// {{{ +{ + $desktop = array (); + $booleans = array ("false" => false, "true" => true); + $data = file_get_contents($path); + $data = str_replace("&", "&", $data); + $lines = explode("\n", $data); + foreach ($lines as $l => $line) { + $line = rtrim($line); + $pos = strpos($line, "="); + if (!$pos) continue; + $field = substr($line, 0, $pos); + $value = substr($line, ($pos + 1)); + if ($value === false) $value = ""; + if (array_key_exists($value, $booleans)) { + $value = $booleans[$value]; + } + + $pos = strpos($field, "["); + if ($pos) { + $field_name = strtolower(substr($field, 0, $pos)); + $key = substr($field, ($pos + 1), -1); + } else { + $field_name = strtolower($field); + } + if ($field_name == "categories") { + if (substr($value, -1) == ";") + $value = substr($value, 0, -1); + $value = explode(";", strtolower($value)); + } + if (!array_key_exists($field_name, $desktop)) { + $desktop[$field_name] = $value; + } else if (!is_array($desktop[$field_name])) { + $default = $desktop[$field_name]; + $desktop[$field_name] = array ("default" => $default); + } else { + $desktop[$field_name][$key] = $value; + } + } + if (!array_key_exists("terminal", $desktop)) + $desktop["terminal"] = false; + return $desktop; +} +// }}} + +function storeEntry($name, $exec, $categories, $menu, $indexes = null, $core = false) +// {{{ +{ + if (is_null($indexes)) { // first call of this function for this desktop file + $indexes = array (); + $indexes["c"] = 0; + $indexes["nc"] = count($categories); + $indexes["lc"] = $indexes["nc"] - 1; + } + + for ($c =& $indexes["c"]; $c < $indexes["nc"]; $c++) { // loop through each category + $category =& $categories[$c]; + if ($category == "application") { + $core = true; + continue; + } + $is_last = ($c == $indexes["lc"]); + if (array_key_exists($category, $menu)) { + $core = false; + if ($is_last) { // put entry in current (sub)menu + $menu[$category][] = array ( + "appname" => $name, + "appexec" => $exec + ); + } else { // look for a matching submenu + ++$c; + $menu[$category] = storeEntry($name, $exec, $categories, $menu[$category], $indexes, $core); + } + return $menu; + } else { // unknown category + if (!$is_last) { + $core = false; + continue; + } else if ($core && $category != "core") { // not a "core" app, not a supported category + $menu["other"][] = array ( + "appname" => $name, + "appexec" => $exec + ); + return $menu; + } else { // last category, put it in current (sub)menu + $menu[] = array ( + "appname" => $name, + "appexec" => $exec + ); + return $menu; + } + } + } + return $menu; +} +// }}} + +function genXML(&$menu, &$labels, $i = 0) +// {{{ +{ + static $x = 0; + $xml = ""; + foreach ($menu as $key => $value) { + $indentation = str_repeat(" ", $i); + if (is_string($key)) { // recursion + list ($label,) = each($labels); // advance pointer no matter what + if (empty($value)) continue; // menu is empty, there's no point in displaying it + $xml .= $indentation . "<menu id=\"gnome-menu-$x\" label=\"$label\">\n"; + $xml .= genXML($menu[$key], $labels[$label], $i + 1, ++$x); + $xml .= $indentation . "</menu>\n"; + } else { + if (empty($value)) continue; + $xml .= $indentation . "<item label=\"{$value["appname"]}\"><action name=\"Execute\">" + . "<execute>{$value["appexec"]}</execute></action></item>\n"; + } + } + return $xml; +} +// }}} + +$categories = array ( + "utility" => array (), + "settings" => array ( + "accessibility" => array (), + "advancedsettings" => array () + ), + "education" => array (), + "game" => array (), + "graphics" => array (), + "network" => array (), + "audiovideo" => array ( + "audio" => array (), + "video" => array () + ), + "office" => array (), + "other" => array (), + "development" => array (), + "science" => array (), + "system" => array () +); + +$menu = array ( + "Accessories" => null, + "Desktop Preferences" => array ( + "Accessibility" => null, + "Advanced" => null + ), + "Education" => null, + "Games" => null, + "Graphics" => null, + "Internet" => null, + "Multimedia" => array ( + "Audio" => null, + "Video" => null, + ), + "Office" => null, + "Other" => null, + "Programming" => null, + "Scientific Tools" => null, + "System Tools" => null +); + +$modifiers = array ("%f", "%F", "%u", "%U", "%d", "%D", "%n", "%N", "%i", "%c", "%k", "%v"); + +$desktops = array (); +$names = array (); +foreach ($dirs as $path) { + $dir = dir($path); + while (($entry = $dir->read()) !== false) { + if (substr($entry, -8) != ".desktop") continue; + $desktop = parseDesktopFile($path . DIRECTORY_SEPARATOR . $entry); + if ($desktop === false || !array_key_exists("categories", $desktop)) continue; + !is_array($desktop["name"]) ? $name = $desktop["name"] : $name = $desktop["name"]["default"]; + $key = & $desktop["exec"]; + $desktops[$key] = $desktop; + $names[$key] = $name; + } +} +asort($names); +reset($names); + +foreach ($names as $key => $name) { + $desktop =& $desktops[$key]; + $exec = str_replace($modifiers, "", $desktop["exec"]); + if ($desktop["terminal"]) $exec = "xterm -e $exec"; + $categories = storeEntry($name, $exec, $desktop["categories"], $categories); +} +?> +<openbox_pipe_menu xmlns="http://openbox.org/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://openbox.org/ + file:///usr/share/openbox/menu.xsd"> + +<?php echo genXML($categories, $menu, 1); ?> + +</openbox_pipe_menu> + |