|
I have just got an ipod mini for my girlfriend. She currently uses myth at home and has no problems with it, however she gets flumuxed like most non-linux people when having to type in a shell.
For her to be able to use the iPod I have set up an automout so that when she plugs it in it gets automatically mounted. The only thing now stopping her from using it is having to eject the ipod, hence this patch (I also filed a wishlist bug #111012 then realised I could probably program it) This patch adds an ipod::eject() function which runs umount and then eject. It also adds a new button \"transfer and eject\" this then transfers the files and calls the ipod::close followed by ipod::eject. I use gentoo and add the line to the end of src_unpack(): [code:1] epatch /root/amarok.patch [/code:1] to apply it when emerging. The Patch: [code:1] diff -ur amarok-1.3/amarok/src/amarokcore/amarokdcophandler.cpp amarok-1.3-new/amarok/src/amarokcore/amarokdcophandler.cpp --- amarok-1.3/amarok/src/amarokcore/amarokdcophandler.cpp 2005-08-14 23:53:18.000000000 +0100 +++ amarok-1.3-new/amarok/src/amarokcore/amarokdcophandler.cpp 2005-08-19 16:16:59.000000000 +0100 @@ -362,6 +362,11 @@ MediaDevice::instance()->transferFiles(); } + void DcopPlayerHandler::ejectIpod() + { + MediaDevice::instance()->ejectIpod(); + } + void DcopPlayerHandler::volumeDown() { EngineController::instance()->decreaseVolume(); diff -ur amarok-1.3/amarok/src/amarokcore/amarokdcophandler.h amarok-1.3-new/amarok/src/amarokcore/amarokdcophandler.h --- amarok-1.3/amarok/src/amarokcore/amarokdcophandler.h 2005-08-14 23:53:18.000000000 +0100 +++ amarok-1.3-new/amarok/src/amarokcore/amarokdcophandler.h 2005-08-19 16:31:44.000000000 +0100 @@ -87,6 +87,7 @@ virtual void volumeDown(); virtual void volumeUp(); virtual void transferDeviceFiles(); + virtual void ejectIpod(); private: virtual void transferCliArgs( QStringList args ); diff -ur amarok-1.3/amarok/src/ipod/ipod.cpp amarok-1.3-new/amarok/src/ipod/ipod.cpp --- amarok-1.3/amarok/src/ipod/ipod.cpp 2005-08-14 23:53:18.000000000 +0100 +++ amarok-1.3-new/amarok/src/ipod/ipod.cpp 2005-08-19 15:44:40.000000000 +0100 @@ -53,6 +53,17 @@ itunesdb.clear(); } +void IPod::eject() { + QString exec_command; + + exec_command = \"umount \" + ipodBase; + system(exec_command.latin1()); + + exec_command = \"eject \" + ipodBase; + system(exec_command.latin1()); + +} + bool IPod::ensureConsistency() { kdDebug() sizeHint().height() ); m_progress->hide(); + QHBox* eb( this ); + eb->setSpacing( 4 ); + m_ejectButton = new QPushButton( SmallIconSet( \"rebuild\" ), i18n( \"Transfer and Eject\" ), eb ); + connect( m_transferButton, SIGNAL( clicked() ), MediaDevice::instance(), SLOT( transferFiles() ) ); + connect( m_ejectButton, SIGNAL( clicked() ), MediaDevice::instance(), SLOT( ejectIpod() ) ); } @@ -580,6 +585,21 @@ void MediaDevice::transferFiles() //SLOT { + transferFiles(0); +} + + +void +MediaDevice::ejectIpod() //SLOT +{ + transferFiles(1); +} + + +void +MediaDevice::transferFiles( int eject ) +{ + m_parent->m_ejectButton->setEnabled( false ); m_parent->m_transferButton->setEnabled( false ); if ( m_ipod->ensureConsistency() ) @@ -629,11 +649,16 @@ m_ipod->unlock(); syncIPod(); fileTransferFinished(); + if (eject==1) { + m_ipod->close(); + m_ipod->eject(); + } } else debug() setEnabled( true ); + m_parent->m_ejectButton->setEnabled( true ); } diff -ur amarok-1.3/amarok/src/mediabrowser.h amarok-1.3-new/amarok/src/mediabrowser.h --- amarok-1.3/amarok/src/mediabrowser.h 2005-08-14 23:53:18.000000000 +0100 +++ amarok-1.3-new/amarok/src/mediabrowser.h 2005-08-19 16:10:21.000000000 +0100 @@ -109,6 +109,7 @@ MediaDeviceList* m_deviceList; KListView* m_transferList; QPushButton* m_transferButton; + QPushButton* m_ejectButton; MediaBrowser* m_parent; }; @@ -133,6 +134,7 @@ public slots: void transferFiles(); + void ejectIpod(); void deleteFiles( const KURL::List& urls ); void deleteFromIPod( MediaItem* item ); @@ -143,6 +145,7 @@ private: void openIPod(); + void transferFiles( int eject ); bool fileExists( const MetaBundle& bundle ); KURL::List m_transferURLs; [/code:1] I welcome any comments on this code. I think this feature and the ability to add playlists are the two that stop amarok from being a great program to use with an ipod. |
|
Forgot to say this only works for me if I have eject setuid root, so it runs as root. Looking at the eject website this seems to be an issue with eject.
|
KDE Developer
|
My two cents is to use one of the KDE APIs instead of system(). We try to avoid scary C lib stuff.
You should submit this is a wish request on bugzilla and attach the patch.
Amarok Developer
|
|
Is there any KDE program/funktion to eject an iPod yet? I\'m experiencing the same problem like mentioned above.
|
Registered Member
|
I implemented mount/umounting in the Media Device browser using the connect button in current svn. To eject the iPod you need to do this.
#chmod a+rsx /path/to/eject And then in the Media Device config dialog set \"eject /path/of/mount\" for the unmount command. The eject command umounts before eject, I\'ve tested this and it works great. Post edited by: madpenguin8, at: 2005/08/27 05:20 |
KDE Developer
|
Well, rather the suid eject I believe you can various options to your fstab. I don\'t have a iPod, but I can eject with my non-suid `eject` with:
/dev/cdroms/cdrom0 /mnt/dvd iso9660 noauto,ro,users 0 0 I believe the key option there is \"users\"
Amarok Developer
|
Registered Member
|
Yep, but without an \"s\" in the end
My 2 cents :whistle: |
Registered Member
|
Sorry, but that\'s wrong. Yes my non-suid eject can eject the cdrom, but in no way can it eject a scsi device regardless of fstab entry.
└─(~)-> eject /mnt/ipod/ eject: unable to open `/dev/scsi/host17/bus0/target0/lun0/part2\' From the eject man page. You need appropriate privileges to access the device files. Running as root or setuid root is required to eject some devices (e.g. SCSI devices). |
KDE Developer
|
|
Registered Member
|
The temporary way I did it now is to add a sudoer so I can write :
sudo eject /dev/IpodDeviceName and it ask my user password but it\'s better than to have to type the root password. |
Registered users: bancha, Bing [Bot], daret, Evergrowing, Google [Bot], lockheed, sandyvee, Sogou [Bot]