Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Gentoo Chat
  • Search

[Openbox Script] Recursive directory listing

Opinions, ideas and thoughts about Gentoo. Anything and everything about Gentoo except support questions.
Post Reply
  • Print view
Advanced search
20 posts • Page 1 of 1
Author
Message
nightm4re
Guru
Guru
User avatar
Posts: 519
Joined: Sun Jun 20, 2004 3:28 am
Location: Providence, RI, USA
Contact:
Contact nightm4re
Website

[Openbox Script] Recursive directory listing

  • Quote

Post by nightm4re » Sat Oct 09, 2004 1:28 am

Hi all,

miqorz suggested I get in gear and make another script, so hey I did. This one takes a directory parameter and outputs a listing from that directory. Subdirs are displayed first, and recursively call the script to generate its submenus (yes, i trimmed the . and ..).

CONFIG OPTIONS (set in the file itself):
- MIME TYPE ACTIONS. Read the script, there's a lot of documentation about what you can do with it. I'm pretty happy with how it came out.
- whether or not it displays file sizes
- whether or not to display files/dirs starting with .

Preview
Script (current version 1.3)

REQUIRES MIME::Types CPAN package. emerge search dev-perl/MIME-Types :D

Changelog:
Bumped to 1.3, changed title, bug fix (thnx), MIME type actions!
Bumped to 1.2, added protection from & signs in files.
Bumped to 1.1, added .file hider.

Post bug reports, feature suggestions, whatever. Enjoy!
Last edited by nightm4re on Sat Oct 09, 2004 11:58 pm, edited 2 times in total.
Nitrogen - GtkMM based background setter/restorer, please test!
Minuslab | d.minuslab.net
Top
miqorz
Veteran
Veteran
User avatar
Posts: 1170
Joined: Sun Apr 04, 2004 7:05 pm
Location: Pissing into the wind.
Contact:
Contact miqorz
Website

  • Quote

Post by miqorz » Sat Oct 09, 2004 1:49 am

This thing kicks ass. Excellent work man.
Want a GUI installer? Use fucking knoppix.
OSX themes suck more than you.. Almost.
Daily Screenshot
Top
denstark
l33t
l33t
User avatar
Posts: 654
Joined: Mon Jun 02, 2003 6:49 pm
Location: sd.ca.us
Contact:
Contact denstark
Website

  • Quote

Post by denstark » Sat Oct 09, 2004 2:19 am

Sweet script. Added here.
Blog

Code: Select all

denstark> starbuck authorizes torture?
rokstar> sure they do, you tried their coffee?
Top
seank
l33t
l33t
Posts: 686
Joined: Thu Jul 08, 2004 1:44 am
Contact:
Contact seank
Website

  • Quote

Post by seank » Sat Oct 09, 2004 6:25 am

You should have a way to open different programs for different types of files. I want to open XMMS for mp3s and I want to open mplayer for for mpegs, etc... There are many differen't types of files, so that config could get big :) -- Then it would be cool to make a config generator that would check for programs on the user's machine to try to find good defaults for them. Kinda like fluxbox-generate-menu.
Top
nightm4re
Guru
Guru
User avatar
Posts: 519
Joined: Sun Jun 20, 2004 3:28 am
Location: Providence, RI, USA
Contact:
Contact nightm4re
Website

  • Quote

Post by nightm4re » Sat Oct 09, 2004 10:48 am

skennedy wrote:You should have a way to open different programs for different types of files. I want to open XMMS for mp3s and I want to open mplayer for for mpegs, etc... There are many differen't types of files, so that config could get big :) -- Then it would be cool to make a config generator that would check for programs on the user's machine to try to find good defaults for them. Kinda like fluxbox-generate-menu.

yeah, i was trying to figure out a good way to do that. I suppose I could just do an extension matching pattern, but I'd rather not do that, as it's a bit clumsy and tedious listing a ton of stuff. A better way would be to look into detecting mime types. I don't know how that's handled in Perl, but in PHP a lot of it is automatic. I'll check it out later today.
Nitrogen - GtkMM based background setter/restorer, please test!
Minuslab | d.minuslab.net
Top
seank
l33t
l33t
Posts: 686
Joined: Thu Jul 08, 2004 1:44 am
Contact:
Contact seank
Website

  • Quote

Post by seank » Sat Oct 09, 2004 5:14 pm

I'm pretty sure there is a module for it on CPAN.
Top
dub.wav
Tux's lil' helper
Tux's lil' helper
Posts: 149
Joined: Wed Apr 09, 2003 12:55 pm
Location: Norway

  • Quote

Post by dub.wav » Sat Oct 09, 2004 7:19 pm

nightmare wrote: yeah, i was trying to figure out a good way to do that. I suppose I could just do an extension matching pattern, but I'd rather not do that, as it's a bit clumsy and tedious listing a ton of stuff. A better way would be to look into detecting mime types. I don't know how that's handled in Perl, but in PHP a lot of it is automatic. I'll check it out later today.
Gnome has a program called gnome-open which will open a file with the default handler. For KDE, I think kfmclient exec ... might do the job.
Top
miqorz
Veteran
Veteran
User avatar
Posts: 1170
Joined: Sun Apr 04, 2004 7:05 pm
Location: Pissing into the wind.
Contact:
Contact miqorz
Website

  • Quote

Post by miqorz » Sat Oct 09, 2004 7:42 pm

dub.wav wrote:
nightmare wrote: yeah, i was trying to figure out a good way to do that. I suppose I could just do an extension matching pattern, but I'd rather not do that, as it's a bit clumsy and tedious listing a ton of stuff. A better way would be to look into detecting mime types. I don't know how that's handled in Perl, but in PHP a lot of it is automatic. I'll check it out later today.
Gnome has a program called gnome-open which will open a file with the default handler. For KDE, I think kfmclient exec ... might do the job.
What about those of us who don't have either installed?
Want a GUI installer? Use fucking knoppix.
OSX themes suck more than you.. Almost.
Daily Screenshot
Top
nightm4re
Guru
Guru
User avatar
Posts: 519
Joined: Sun Jun 20, 2004 3:28 am
Location: Providence, RI, USA
Contact:
Contact nightm4re
Website

  • Quote

Post by nightm4re » Sat Oct 09, 2004 8:07 pm

miqorz wrote:
What about those of us who don't have either installed?
prolly a combo of some sort is in order. I checked out the module on CPAN already, not bad, im just gonna figure out how i want to set up the config for everything. I'll prolly make it a config option to use the gnome/kde handlers.
Nitrogen - GtkMM based background setter/restorer, please test!
Minuslab | d.minuslab.net
Top
seank
l33t
l33t
Posts: 686
Joined: Thu Jul 08, 2004 1:44 am
Contact:
Contact seank
Website

  • Quote

Post by seank » Sat Oct 09, 2004 8:08 pm

When I tried to use "/" as my directory, it gave me this error:

Code: Select all

Modification of non-creatable array value attempted, subscript -1 at .config/openbox/scripts/dirlist.pl line 77.
I fixed the error by changing line 76 (@chunks = split /\//, $dir;) to

Code: Select all

if ($dir eq "/") {
        $chunks[0] = "/";
} else {
        @chunks = split /\//, $dir;
}
EDIT: I modified the fix a little :P
Last edited by seank on Sat Oct 09, 2004 8:13 pm, edited 2 times in total.
Top
placeholder
Advocate
Advocate
Posts: 2500
Joined: Sat Feb 07, 2004 12:15 am

  • Quote

Post by placeholder » Sat Oct 09, 2004 8:10 pm

In python you could just branch off with:

Code: Select all

if "png" in foo:
           command = "foo"
Then you could have the variable command be what the file gets opened with. In perl I am not sure of the syntax, but the concept should help.
Top
miqorz
Veteran
Veteran
User avatar
Posts: 1170
Joined: Sun Apr 04, 2004 7:05 pm
Location: Pissing into the wind.
Contact:
Contact miqorz
Website

  • Quote

Post by miqorz » Sat Oct 09, 2004 8:14 pm

Pwnz3r wrote:In python you could just branch off with:

Code: Select all

if "png" in foo:
           command = "foo"
Then you could have the variable command be what the file gets opened with. In perl I am not sure of the syntax, but the concept should help.
Hm, what about if I had a file called Knopng for some reason?
Want a GUI installer? Use fucking knoppix.
OSX themes suck more than you.. Almost.
Daily Screenshot
Top
seank
l33t
l33t
Posts: 686
Joined: Thu Jul 08, 2004 1:44 am
Contact:
Contact seank
Website

  • Quote

Post by seank » Sat Oct 09, 2004 8:15 pm

Pwnz3r wrote:In python you could just branch off with:

Code: Select all

if "png" in foo:
           command = "foo"
Then you could have the variable command be what the file gets opened with. In perl I am not sure of the syntax, but the concept should help.
Linux doesn't rely on extensions. It would be best to check the mime type. And what if my filename was png.txt?
Top
nightm4re
Guru
Guru
User avatar
Posts: 519
Joined: Sun Jun 20, 2004 3:28 am
Location: Providence, RI, USA
Contact:
Contact nightm4re
Website

  • Quote

Post by nightm4re » Sat Oct 09, 2004 8:20 pm

skennedy wrote:When I tried to use "/" as my directory, it gave me this error:

Code: Select all

Modification of non-creatable array value attempted, subscript -1 at .config/openbox/scripts/dirlist.pl line 77.
I fixed the error by changing line 76 (@chunks = split /\//, $dir;) to

Code: Select all

if ($dir eq "/") {
        $chunks[0] = "/";
} else {
        @chunks = split /\//, $dir;
}
EDIT: I modified the fix a little :P
hehe, alright i'll throw that in there. didn't think about that.

and ya, mime types are the way to go, however, the CPAN module that deals with them really just deals with extensions, from what I saw in the code. I'll give that a look at in a few minutes.
Nitrogen - GtkMM based background setter/restorer, please test!
Minuslab | d.minuslab.net
Top
placeholder
Advocate
Advocate
Posts: 2500
Joined: Sat Feb 07, 2004 12:15 am

  • Quote

Post by placeholder » Sat Oct 09, 2004 8:28 pm

miqorz wrote:
Pwnz3r wrote:In python you could just branch off with:

Code: Select all

if "png" in foo:
           command = "foo"
Then you could have the variable command be what the file gets opened with. In perl I am not sure of the syntax, but the concept should help.
Hm, what about if I had a file called Knopng for some reason?
Then.....

Code: Select all

if ".png" in foo:
           command = "foo"
Top
slarti`
Retired Dev
Retired Dev
User avatar
Posts: 376
Joined: Sat Sep 20, 2003 3:04 pm
Location: UK
Contact:
Contact slarti`
Website

  • Quote

Post by slarti` » Sat Oct 09, 2004 8:35 pm

app-misc/run-mailcap is installed on virtually all Gentoo systems. It uses /etc/mailcap. It would be a good, standardised way to handle associations. That /etc/mailcap file is a bit lacking though...
Gentoo/AMD64, shell-tools, net-mail, vim, recruiters
IRC: slarti @ irc.freenode.net
Devspace
Top
nightm4re
Guru
Guru
User avatar
Posts: 519
Joined: Sun Jun 20, 2004 3:28 am
Location: Providence, RI, USA
Contact:
Contact nightm4re
Website

  • Quote

Post by nightm4re » Sat Oct 09, 2004 8:41 pm

slarti] wrote:app-misc/run-mailcap is installed on virtually all Gentoo systems. It uses /etc/mailcap. It would be a good, standardised way to handle associations. That /etc/mailcap file is a bit lacking though...
it.. doesn't have extensions tho. just mime types and what to do with them.
Nitrogen - GtkMM based background setter/restorer, please test!
Minuslab | d.minuslab.net
Top
nightm4re
Guru
Guru
User avatar
Posts: 519
Joined: Sun Jun 20, 2004 3:28 am
Location: Providence, RI, USA
Contact:
Contact nightm4re
Website

  • Quote

Post by nightm4re » Sat Oct 09, 2004 11:53 pm

1.3 released, grab it from top thread. This adds support for actions based on MIME types.

I'm real happy with how this came out, it makes things really cool.

It replaces "%1" in your action string with the file, meaning your command doesn't have to be just a prefix, the file can be anywhere in the action. You can even make it run a script by just making the action %1, or do nothing by leaving %1 out of it "true".

First, a default action should be defined. My example uses "gedit %1", but you could set it to another editor or just "true" for unrecognized types.

Second, scroll down a bit, you'll see where to define mime types. You can define them specific (text/plain) or as a range (video/*). Be aware, specific take precendence over ranged, so you can open all text/* files in gedit, but open text/comma-separated-values in gnumeric. The third param (run in terminal) to define a mime type is optional, just set it to 1 if you want it to do so.

That should be all, use it, find some bugs :D
Nitrogen - GtkMM based background setter/restorer, please test!
Minuslab | d.minuslab.net
Top
seank
l33t
l33t
Posts: 686
Joined: Thu Jul 08, 2004 1:44 am
Contact:
Contact seank
Website

  • Quote

Post by seank » Sun Oct 10, 2004 8:19 pm

I found a small bug. It doesn't work with directories that have a space in their name.
Top
nightm4re
Guru
Guru
User avatar
Posts: 519
Joined: Sun Jun 20, 2004 3:28 am
Location: Providence, RI, USA
Contact:
Contact nightm4re
Website

  • Quote

Post by nightm4re » Sun Oct 10, 2004 8:32 pm

yep, i see the problem. the argument to the script needs to be quoted. i'll add it sometime tonight.
Nitrogen - GtkMM based background setter/restorer, please test!
Minuslab | d.minuslab.net
Top
Post Reply
  • Print view

20 posts • Page 1 of 1

Return to “Gentoo Chat”

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

 

 

magic