#!/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: "
... " 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/