Kiobashin.
Stupid kioslaves for the masses.
What is kiobashin?
You are probably a KDE linux user, if you are reading this. And probably you already know that a kioslave is something handles a virtual file system under KDE.
Well. I like KDE very much and I wanted to write something using KDevelop. After one or two minutes I realized that KDE programming is really easy and I decided to write something as stupid as cool. Here you are kiobashin, which is a Kio-slave that allow you to write your personal kioslave... using plain bashscripts.
What is surprising is that it was written in about 4 hours. And I'm not a C++ programmer.


How to get Kiobashin?
Well. Download the sources here:

kiobashin.kdevelop-0.1.tar.gz

What kind of license? Nothing. Take it and do what you want.
Untar and do the classical ./configure && make && make install as root. That's all.
Create a directory called kiobashin in your home directory and copy the bashscripts you found under the kiobashin-scripts folders. End of the installation.


How to use Kiobashin?
Open konqueror and go to kiobashin:/. There are all the avaible scripts shown as folders. Simply click on one of these and happy browsing!
Let's try the "kwedshin.sh" script. Click the script's folder.


remix.kwed.org is a very nice MP3 site. It has lotsa of Commodore 64 remixes... and is one of my favourite sites. Well... let's see how I've "kiobashined©" the homepage...


Hey! Seems like the "kwedshin.sh" folder contains some MP3s organized by author! ;) Saying the truth these MP3s aren't downloaded. The homepage was a bit grepped and reformatted by a script and the content was sent to kiobashin. However looks like a well organized folder!


How to listen the MP3s? Let's simply copy the MP3s like any file on the desktop, on a folder or directly on your MP3 player! LOOL! Don't try to launch directly these files... Kiobashin is still a bit buggy... :)


How it works?
Really simple. The kiobashin root shows all your *.sh scripts in your "kiobashin" directory in your home.
When you "go into" a kiobashin script, it runs the script and parses the output. How?

yourscript.sh *dir [subpath]
Where subpath are all the current path levels passed as parameters. For example:

yourscript.sh *dir

Will be called when you are at kiobashin://yourscript.sh/.

yourscript.sh *dir "folder 1" "subfolder 3"

Will be called when you are at kiobashin://yourscript.sh/folder 1/subfolder 3.

When the script is called, it must return some stuff that descripts the virtual directory in this way:

1. If you want a folder simply echo a "*" with the folder name.
*This is the folder name

2. If you want a file, echo a "." with the file name...
.filename.mp3
...and another line that describes the file...
300*audio/mpeg3
...that means an MP3 that is 300K big.

That's all for directory listing. You can test directly your script from the command line...

kes@kesiev:~/kiobashin$ bash kwedshin.sh *dir
*Andreas Bauernfeind
*Antony Crowther (Ratt)
*Ben Daglish
*Chris Hülsbeck
*David Whittaker
*Eddie Svärd (Hank)
*Edwin van Santen
*Ian W. Crabtree
*Jeroen Tel - Maniacs of Noise
*Johan Åstrand (Zyron)
*John A. Fitzpatrick
*Jonathan Dunn
*Juha-Matti Hilpinen (AMJ)
*Kai Walter (PVCF)
*Keith Miller
*Keith Tinman
*Kris Hatlelid
*Mark Cooksey
*Mark Waldaukat (Heinmukk)
*Markus Schneider
*Martin Galway
*Matt Gray
*Michael Hendriks
*Nick Scarim
*Richard Joseph
*Rob Hubbard
*Rob Hubbard & Jori Olkkonen
*Sami Seppä (Rock)
*Shaun Southern
*Thomas E. Petersen (Laxity)
*Tim & Geoff Follin
*Tim Follin
*Unknown
*Wojciech Radziejewski (Shogoon)
kes@kesiev:~/kiobashin$ bash kwedshin.sh *dir "Edwin van Santen"
.Putzi - PCW-tune 88 'Engel-mix'.mp3
0*audio/mpeg3
kes@kesiev:~/kiobashin$

Really easy, isn't it?
Well... now let's explain how kiobashin retrieve files. The kiobashin script is called with the first argument as *mime when the kioslave asks which type is your file. Usually is the same used when you are describing a file. For example, when the kioslave asks which mimetype is the file foo.mp3 into the virtual folder kiobashin://yourscript.sh/my Mp3s/misc/, kiobashin calls:

yourscript.sh *mime "my Mp3s" "misc" "foo.mp3"

it will return only the mime type...

kes@kesiev:~/kiobashin$ bash yourscript.sh *mime "my Mp3s" "misc" "foo.mp3"
audio/mpeg3

If kiobashin needs the real file, it will call the script using the *file second parameter. The real file must be simply cated from the script: it will be piped directly to the system. For example: if we have a virtual file called readme.txt into the folder kiobashin://yourscript.sh/virtual docs/more stuff/, kiobashin calls:

yourscript.sh *file "virtual docs" "more stuff" "readme.txt"

Running it from the command line, it will show the pure file.

kes@kesiev:~/kiobashin$ bash yourscript.sh *file "virtual docs" "more stuff" "readme.txt"
This is a virtual readme
that isn't a real file on the hard disk!

Clear? Look the test.sh kiobashin script for a clearer example.


Why Kiobashin?
Any particular reason. I just wanna know how hard should be write a virtual filesystem for KDE and now I'm impressed about how easy is. I've just expanded the example provided by KDevelop. And not too much! KDE is a really cool and easy enviroment and has a really well-organized structure. I think that lacks a more n00b-friendly code editor (cough cough... code autocompletion...) and an updated tutorial.


Your Feedback!
Some suggestions? A good tutorial for KDE application development? Two friendly words? Write @ kesiev@hotmail.com. I'll surely answer to you!