-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed auto-reload and improved script
- Loading branch information
Showing
5 changed files
with
69 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (C) 2014 Smith AR <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
|
@@ -16,9 +15,12 @@ | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# | ||
# Version 1.3 | ||
# dolphin-folder-color.sh ICON_NAME PATH1 PATH2 ... | ||
# name: is a color or any other folder-$icon or freedesktop icon | ||
# Version 1.4 | ||
|
||
### USAGE: | ||
# dolphin-folder-color.sh <ICON_NAME> [PATH1] [PATH2] ... | ||
# <ICON_NAME>: is a color or any other folder-$icon or freedesktop icon | ||
######################################################################### | ||
|
||
shopt -s extglob | ||
icon=${1:?'Name or color icon is not present'} ; shift | ||
|
@@ -27,39 +29,46 @@ tmp=$TMPDIR/$desktopEntry-$PPID | |
|
||
|
||
case $icon in | ||
default | black | blue | brown |\ | ||
cyan | green | grey | orange |\ | ||
red | violet | yellow |\ | ||
bookmark | remote | tar | sound |\ | ||
temp | txt | text | video | videos |\ | ||
activities | development | documents | html |\ | ||
favorites | download | downloads | locked |\ | ||
image | images | image-people | important |\ | ||
network | templates | public | publicshare | print ) | ||
|
||
if [ $icon != 'default' ] ; then | ||
icon="folder-$icon" | ||
fi | ||
;; custom ) | ||
icon=$(kdialog --caption 'Folder Color' --title 'Select Icon' \ | ||
--geticon Desktop Place 2> /dev/null) | ||
if [ ${#icon} = 0 ] | ||
then exit | ||
fi | ||
;; *) | ||
if ! [ -f $(kiconfinder $icon) ] ; then | ||
icon="default" | ||
fi | ||
default | black | blue | brown |\ | ||
cyan | green | grey | orange |\ | ||
red | violet | yellow |\ | ||
bookmark | remote | tar | sound |\ | ||
temp | txt | text | video | videos |\ | ||
activities | development | documents | html |\ | ||
favorites | download | downloads | locked |\ | ||
image | images | image-people | important |\ | ||
network | templates | public | publicshare | print ) | ||
|
||
if [ $icon != 'default' ] ; then | ||
icon="folder-$icon" | ||
fi | ||
;; custom ) | ||
icon=$(kdialog --caption 'Folder Color' --title 'Select Icon' \ | ||
--geticon Desktop Place 2> /dev/null) | ||
if [ ${#icon} = 0 ] | ||
then exit | ||
fi | ||
;; *) | ||
if ! [ -f $(kiconfinder $icon) ] ; then | ||
icon="default" | ||
fi | ||
esac | ||
|
||
for dir in "$@" ; do | ||
cd "$dir" | ||
tag=$(grep 'Icon=.*' $desktopEntry) | ||
header=$(grep '\[Desktop Entry\]' $desktopEntry) | ||
|
||
if [ -d "$dir" ] && [ -w $desktopEntry ] && [ -n "$(< $desktopEntry)" ] ; then | ||
icon=${icon//+(\/)/\\/} | ||
for dir in "$@" ; do | ||
|
||
if [ -d "$dir" ] ; then | ||
cd "$dir" | ||
else | ||
echo "Directory not found: $dir" ; continue | ||
fi | ||
|
||
if [ -w $desktopEntry ] && [ -n "$(< $desktopEntry)" ] ; then | ||
|
||
tag=$(grep 'Icon=.*' $desktopEntry) | ||
header=$(grep '\[Desktop Entry\]' $desktopEntry) | ||
icon=${icon//+(\/)/\\/} ##syntax ${parameter//pattern/string} | ||
|
||
if [ $icon = 'default' ] ; then | ||
sed '/Icon=.*/d' $desktopEntry > $tmp | ||
|
||
|
@@ -82,12 +91,29 @@ for dir in "$@" ; do | |
cat $tmp > $desktopEntry | ||
rm $tmp | ||
|
||
elif [ -d "$dir" ] && [ $icon != 'default' ] ; then | ||
elif [[ $icon != 'default' ]] ; then | ||
echo -e "[Desktop Entry]\nIcon=$icon" > $desktopEntry | ||
fi | ||
|
||
|
||
## Return to parent directory | ||
cd .. | ||
done | ||
|
||
service="org.kde.dolphin-$PPID" | ||
# Reload the Dolphin windows with qdbus | ||
method='/dolphin/Dolphin_1/actions/reload org.qtproject.Qt.QAction.trigger' | ||
qdbus $service $method &> /dev/null | ||
service='org.kde.dolphin-' | ||
reloaded=false | ||
|
||
for pid in $(pidof "dolphin") ; do | ||
if [ $pid = $PPID ] ; then | ||
qdbus $service$PPID $method &> /dev/null | ||
reloaded=true | ||
fi | ||
done | ||
|
||
if ! $reloaded ; then | ||
for pid in $(pidof "dolphin") ; do | ||
qdbus $service$pid $method &> /dev/null | ||
done | ||
fi | ||
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters