LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Mandriva
User Name
Password
Mandriva This Forum is for the discussion of Mandriva (Mandrake) Linux.

Notices

Reply
 
Search this Thread
Old 03-02-2005, 03:42 PM   #1
justintime32
Member
 
Registered: Sep 2004
Distribution: SimplyMepis 3.3 (Debian testing/unstable)
Posts: 123

Rep: Reputation: 15
Exclamation Need help writing a simple program


Hey,

I just persuaded my friend to get rid of windows and put mandrake linux on it. So he did, and he is mostly happy with it except for one problem. When he plugs his digital camera in, Konqueror stops working. I know this can probably be fixed by disabling KDE from putting an icon on the desktop, but I want to make a small program that can copy pictures from his camera automatically.

Here's what I'm thinking: It will ask you what you want the group of pictures to be called... You type something in and hit enter, and it will first create a directory with that name in the "~/My Pictures/" folder. After that, it will display the text "Coppying..." and then copy all the files from "/mnt/removable/" (since it has movies too) into "~/My Pictures/(whatever directory it created)/". After it does that, it will say "Done, would you like to delete the pictures from the camera? (yes or no)". Obviously it will delete all files in the "/mnt/removable/" folder if yes, and will not if no. After it deletes (or doesn't delete) the files, it will run "konqueror ~/My Pictures/(directory)/" and then exit.

I think that this can be done with a simple shell script, but I may be wrong. I know next to nothing about programming and am still generally new to Linux. If it does need to be compiled or anything like that, that's fine too. Any help is greatly appreciated. Thanks in advance if you do help me out.
 
Old 03-02-2005, 04:21 PM   #2
justintime32
Member
 
Registered: Sep 2004
Distribution: SimplyMepis 3.3 (Debian testing/unstable)
Posts: 123

Original Poster
Rep: Reputation: 15
I suppose I should have put this in programming...
Could a mod here please move it?
 
Old 03-02-2005, 04:21 PM   #3
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
I think the Programming forum would have been a better place to post this. One of the mods will probably move it for you

That sounds interesting, though; are you thinking of a command-line interface, or something with a GUI? I'm not sure about the feasibility of running something like that automatically - it would have to be called by a USB hotplug event of some kind, so that when you plug the camera in, it knows what program to run. It'd probably be easier to make it a manually-run operation; just plug in camera, then run the program.

In my experience, there's not really a need to mount the camera as a removable drive. gphoto2 usually detects the camera as being there, and can copy files directly from the camera to a location on the hard drive (and it can even delete the ones on the camera afterwards). It might be different for your friend's camera, though. I have a Kodak DX3600, which is well-supported by gphoto2. Your friend might not be so lucky.

A quick little GUI to do the things you described wouldn't be too hard, but first I would want to know if something might already exist for that. If not, it ought to! I've only used GTKam for downloading stuff from my camera (which, while a good program overall, seems somewhat unstable at times, and I've often resorted to using gphoto2 via the command-line - not a bad interface, either way, and easily scriptable). I think this could make for a pretty useful piece of software; it's special-purpose, and could be the easiest way for Linux newbies to get photos off their camera.

And to answer your question (if a GUI is what you were thinking of): yes, you can do GUIs from a shell script. perlGTK and wxPython are a couple APIs I know of; not sure which API would be best for this tool, but if I were to write it I'd probably use wxPython (since I already know it).

I think this could be a fun project! Let me know more details about what you have in mind.

Last edited by wapcaplet; 03-02-2005 at 04:23 PM.
 
Old 03-02-2005, 04:24 PM   #4
justintime32
Member
 
Registered: Sep 2004
Distribution: SimplyMepis 3.3 (Debian testing/unstable)
Posts: 123

Original Poster
Rep: Reputation: 15
Yes, I mean that he would plug in the camera and run a program on the desktop. No GUI needed, it would be text and open in a terminal (probably Konsole), but if anyone here has enough free time, a GUI would be fine.

And, also, this camera is not a true camera, it is just seen as flash removable memory (by windows and linux. In fact, it even works as XBox memory). Mandrake automatically mounted it as /mnt/removable, and that is fine.

Last edited by justintime32; 03-02-2005 at 04:30 PM.
 
Old 03-02-2005, 07:25 PM   #5
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Sounds fairly easy to do. The disadvantage of a GUI is that it would probably require extra libraries to be installed. A simple shell script could accomplish the same task, as long as the shortcut (in KDE or wherever) is set to "run in terminal", so you can have some interaction with it.

How's this sound:

Hook up camera (or memory card, or whatever)
Run program:

1. Get pictures from where? (use gphoto2 or mounted media like /mnt/removable. Check mounted media at this point to make sure something is there. Could even show a list of cameras accessible through gphoto2 - always thinking about users with a gphoto2-supported camera. Of course, if gphoto2 isn't installed, don't worry about it.)
2. Save pictures where? (default ~/My Pictures, or maybe even default to last place you saved pictures)
3. Name for the group of pictures? (default: whatever they're called on the camera)
4. Copying pictures... (files copied from mounted media or through gphoto2)
5. Done. Delete pictures from camera/media? (Y/N)
6. Preview pictures in another program? (default: Konqueror)

Does this sound like a good approach? If I'm going to build something like this, I want it to be powerful enough to handle more general cases, and give the user some choices (and intelligent defaults), instead of assuming too much.

If you think this sounds good, I will work on implementing it! I'll probably just use a regular shell script (instead of bash), so it will be very portable (even to non-Linux platforms).

Then, if it goes well and people like it, we could try doing a GUI. Either way, it should be fun!
 
Old 03-02-2005, 09:42 PM   #6
justintime32
Member
 
Registered: Sep 2004
Distribution: SimplyMepis 3.3 (Debian testing/unstable)
Posts: 123

Original Poster
Rep: Reputation: 15
Sounds pretty good. I just made a beta version of it. Right now it's pretty basic - it doesn't ask where to get the pictures from or where to put them (because that's the one I made for my friend). I can email it to you, PM me your email.
 
Old 03-02-2005, 10:08 PM   #7
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
I don't have PM... just send it to me at wapcaplet99 at yahoo dot com.
 
Old 03-04-2005, 08:08 PM   #8
justintime32
Member
 
Registered: Sep 2004
Distribution: SimplyMepis 3.3 (Debian testing/unstable)
Posts: 123

Original Poster
Rep: Reputation: 15
Uh... Everyone has PM (private messaging).
Anyway, I sent you an email. Did you get it?
 
Old 03-04-2005, 09:12 PM   #9
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Whenever I try to use PM, I get a message saying I need to be a contributing member to use it.

I haven't gotten your email yet. Maybe it's just being slow. Could you post it here in the forum?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
writing simple acpi program bucovaina78 Linux - Laptop and Netbook 1 04-27-2005 08:46 PM
Help writing a simple script Garibaldi3489 Linux - General 10 12-18-2004 07:22 PM
writing a simple file system in linux Deepthi_57 Linux - Newbie 1 05-03-2004 01:42 AM
Simple script writing help - digital camera EuroJovi Linux - General 2 02-01-2004 05:01 PM
Writing a simple KDE application yapp Programming 1 12-10-2003 04:39 PM


All times are GMT -5. The time now is 12:27 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration