Probably two things I do most that require me to drop into a shell are checking a files md5sum:
md5sum Downloads/isofiles/VBoxGuestAdditions-4.0.2.iso
b87a42646972054481bcc2541dc04a09 Downloads/isofiles/VBoxGuestAdditions-4.0.2.isofiles
and running du -sh on a directory to see how big it is:
$ du -sh MyDocuments
3.6G MyDocuments
I always thought it would be nice to be able to select a file and right-click and select md5sum, or select a directory and right-click and select Disk Usage. Well it turns out that it's not difficult at all to make this happen in Kubuntu. It requires only 3 things:
1. DEPENDANCIES: All you need is kdialog which if you are using kubuntu it is part of kde-baseapps-bin and is most likely installed already. You would also need md5sum and du which are both in coreutils and are most likely installed.
2. SCRIPTS: You need scripts to do the md5 and du calculations and output the results in kdialog. I wrote a couple simple scripts I'll include, but feel free to create your own more elaborate scripts.
3. SERVICEMENUS: To put the Actions: md5sum and diskusage in dolphin you need to create the ServiceMenus files and put them in /usr/share/kde4/services/ServiceMenus. I created md5_generate.desktop and du_generate.desktop which should do the job.
So here are the scripts:
$HOME/bin/diskusage
$HOME/bin/md5
The above scripts can be placed anywhere you choose, just make sure they are executable and put the path in the ServiceMenu file, See Below in ServiceMenus files.
The following ServiceMenus files must be placed in the KDE4 ServiceMenus directory:
/usr/share/kde4/services/ServiceMenus
du_generate.desktop
md5_generate.desktop
Thats all there is to it. Now when you are in Dolphin and you decide to check the md5sum of a file or the disk usage of a directory all you have to do is select the files or directories and right-click, Actions and selsct "Display disk usage..." or "Generate MD5SUM for file..."
I hope maybe this is something you can use. If not then maybe you can post something you did with ServiceMenus that you think could be useful to others here.
<edit> Added full path to the scripts.
You may have noticed I simply took an existing servicemenu file and modified it, that is why the Icon is set to cdrom, you can change that.
md5sum Downloads/isofiles/VBoxGuestAdditions-4.0.2.iso
b87a42646972054481bcc2541dc04a09 Downloads/isofiles/VBoxGuestAdditions-4.0.2.isofiles
and running du -sh on a directory to see how big it is:
$ du -sh MyDocuments
3.6G MyDocuments
I always thought it would be nice to be able to select a file and right-click and select md5sum, or select a directory and right-click and select Disk Usage. Well it turns out that it's not difficult at all to make this happen in Kubuntu. It requires only 3 things:
1. DEPENDANCIES: All you need is kdialog which if you are using kubuntu it is part of kde-baseapps-bin and is most likely installed already. You would also need md5sum and du which are both in coreutils and are most likely installed.
2. SCRIPTS: You need scripts to do the md5 and du calculations and output the results in kdialog. I wrote a couple simple scripts I'll include, but feel free to create your own more elaborate scripts.
3. SERVICEMENUS: To put the Actions: md5sum and diskusage in dolphin you need to create the ServiceMenus files and put them in /usr/share/kde4/services/ServiceMenus. I created md5_generate.desktop and du_generate.desktop which should do the job.
So here are the scripts:
$HOME/bin/diskusage
Code:
#!/bin/bash # $HOME/bin/diskusage # this script can be called from a servicemenu file or from the command prompt # Usage: diskusage [directory1] [directory2] ... display_message() { kdialog --title "$title" --msgbox "$message" & } ERROR="0" while [[ "$1" ]];do DIR="$1" shift DIRNAME="$(basename ${DIR})" # Check disk usage of file or directory if !(test -a "${DIR}" );then ((ERROR++)) title="Error directory does not exist!" message=" Directory \`${DIR}' does not exist! " display_message else title="Check Disk Usage of ${DIRNAME}" DU=( $(du -sh "$DIR") ) message="Disk Usage => $DIR: \n ${DU[0]}" display_message #echo "${DU[@]}" #You can enable this line for some console output fi done exit "$ERROR"
Code:
#!/bin/bash # $HOME/bin/md5 # this script can be called from a servicemenu file or from the command prompt # Usage: md5 [file1] [file2] ... display_message() { kdialog --title "$title" --msgbox "$message" & } # Check md5 of file ERROR="0" while [[ "$1" ]];do file="$1" shift filename="$(basename ${file})" if !(test -f "${file}");then ((ERROR++)) title="Error file does not exist!" message=" File \`${file}' does not exist! " display_message else title="Check MD5 of ${filename}" MD5=( $(md5sum "$file") ) message="MD5 for $file: \n ${MD5[0]}" display_message #echo "${MD5[@]}" #You can enable this line for some console output fi done exit "$ERROR"
The following ServiceMenus files must be placed in the KDE4 ServiceMenus directory:
/usr/share/kde4/services/ServiceMenus
du_generate.desktop
Code:
[Desktop Entry] Actions=DisplayDiskUsage; Type=Service ServiceTypes=KonqPopupMenu/Plugin MimeType=all/all; [Desktop Action DisplayDiskUsage] Exec=$HOME/bin/diskusage %F Name=Display disk usage... Icon=cdrom X-Ubuntu-Gettext-Domain=desktop_extragear-multimedia_k3b
md5_generate.desktop
Code:
[Desktop Entry] Actions=GenerateMD5SUM; Type=Service ServiceTypes=KonqPopupMenu/Plugin MimeType=all/all; [Desktop Action GenerateMD5SUM] Exec=$HOME/bin/md5 %F Name=Generate MD5SUM for file... Icon=cdrom X-Ubuntu-Gettext-Domain=desktop_extragear-multimedia_k3b
I hope maybe this is something you can use. If not then maybe you can post something you did with ServiceMenus that you think could be useful to others here.
<edit> Added full path to the scripts.
You may have noticed I simply took an existing servicemenu file and modified it, that is why the Icon is set to cdrom, you can change that.
Comment