Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Desktop Environments
  • Search

process info in fluxbox menu

Problems with GUI applications? Questions about X, KDE, Gnome, Fluxbox, etc.? Come on in. NOTE: For multimedia, go up one forum
Post Reply
Advanced search
6 posts • Page 1 of 1
Author
Message
dr_strange
Guru
Guru
User avatar
Posts: 480
Joined: Tue Apr 16, 2002 7:19 pm
Location: Cambridge, UK

process info in fluxbox menu

  • Quote

Post by dr_strange » Sat Aug 23, 2003 7:27 pm

I've always envied those dynamic menus I see on pekwm screenshots - especially the procinfo part. I thought it would be nice to have something at least similar in fluxbox. So I wrote this very crude hack - it is the very first Python script in my life, so bear with me... Feel free to modify, extend, point out errors etc.

1. Edit your flux menu to contain the following section:

Code: Select all

[submenu] (procinfo) {}
    	[include] (/usr/share/commonbox/fbprocmenu.txt)
[end]
2. Save the following script as fbprocmenu to /usr/bin :

Code: Select all

#!/usr/bin/env python2.2

import sys,os,string
from time import sleep

while 1:
	os.system("ps axh -o pid= -o comm=  > /usr/share/commonbox/fbproc.txt")
	os.system("touch /usr/share/commonbox/fbprocmenu.txt")
	fh = open('/usr/share/commonbox/fbproc.txt', 'r+')
	ft = open('/usr/share/commonbox/fbprocmenu.txt', 'r+')
	ft.write('[begin]  (procinfo) {}\n')
	for line in fh.readlines():
		line = line[:-1]
		line = "     [exec] (kill "+line+") {kill "+line+"}\n"
		ft.write(line)
	ft.write('[end]')	
	fh.close()
	ft.close()
	sleep(5)
	os.system("rm /usr/share/commonbox/fbprocmenu.txt")
Do not forget to make it executable.

3. To run it automatically, put it to your .xinitrc:

exec fbprocmenu &

The result can be seen here.

I am sure it can be improved much, to contain more info etc.
Top
Anacific
Apprentice
Apprentice
User avatar
Posts: 210
Joined: Thu Jun 05, 2003 8:30 pm
Location: Toronto, Canada

  • Quote

Post by Anacific » Sat Aug 23, 2003 8:00 pm

Oh, I like it. I'll give this a try once get home!
warning: `class GroveImpl' only defines a private destructor and has no friends.
Top
nokiaxv2
n00b
n00b
Posts: 5
Joined: Tue Jun 10, 2003 2:22 am

gave it a shot...

  • Quote

Post by nokiaxv2 » Sat Aug 23, 2003 8:57 pm

I was in midstream of typing up an explanation of what I did because I couldn't get it to work for some odd reason.

When i attempted to create the .xinitrc file and add the code to process the script at startup, my xserver would always fail.

So, following all the other instructions and removing the .xinitrc file to get back into fluxbox to start over, I happened to go over the proc info menu and noticed it worked.

So maybe those of you who don't have the .xinitrc file won't need it at all. Good job dr_strange.
-( nokia )-
Top
dr_strange
Guru
Guru
User avatar
Posts: 480
Joined: Tue Apr 16, 2002 7:19 pm
Location: Cambridge, UK

Re: gave it a shot...

  • Quote

Post by dr_strange » Sat Aug 23, 2003 9:10 pm

nokiaxv2 wrote:I was in midstream of typing up an explanation of what I did because I couldn't get it to work for some odd reason.

When i attempted to create the .xinitrc file and add the code to process the script at startup, my xserver would always fail.

So, following all the other instructions and removing the .xinitrc file to get back into fluxbox to start over, I happened to go over the proc info menu and noticed it worked.

So maybe those of you who don't have the .xinitrc file won't need it at all. Good job dr_strange.
They possibly use some *dm to start X.
Top
dr_strange
Guru
Guru
User avatar
Posts: 480
Joined: Tue Apr 16, 2002 7:19 pm
Location: Cambridge, UK

  • Quote

Post by dr_strange » Sun Aug 24, 2003 5:54 pm

I have rewritten it a little bit, now the script looks like this:

Code: Select all

#!/usr/bin/env python2.2

import sys,os,string
from time import sleep

while 1:
	os.system("ps axh -o pid= -o comm=  -o stat=fbprocmenu> /usr/share/commonbox/fbproc.txt")
	os.system("touch /usr/share/commonbox/fbprocmenu.txt")
	fh = open('/usr/share/commonbox/fbproc.txt', 'r+')
	ft = open('/usr/share/commonbox/fbprocmenu.txt', 'r+')
	ft.write('[begin]  (procinfo) {}\n')
	for line in fh.readlines():
		line = line[:-1]
		line = "[submenu]  "+"("+line+") {}\n    [exec] (kill) {kill -9 "+line+"}\n   [exec]"\
		+" (restart) {kill -18 "+line+"}\n    [exec] (terminate) {kill -15 "+line+"}\n[end]\n"
		ft.write(line)
	ft.write('[end]')	
	fh.close()
	ft.close()
	sleep(5)
	os.system("rm /usr/share/commonbox/fbprocmenu.txt")
And the result looks like this.
Top
dr_strange
Guru
Guru
User avatar
Posts: 480
Joined: Tue Apr 16, 2002 7:19 pm
Location: Cambridge, UK

  • Quote

Post by dr_strange » Tue Aug 26, 2003 7:50 am

I know that it would be a better solution to get the process info directly from /proc, and not run ps every 5 seconds; but at the moment I do not know how to gain the info I need.
Top
Post Reply

6 posts • Page 1 of 1

Return to “Desktop Environments”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy