Browse Source

Added action defined icons to be shown with the notifications (manual needs to be corrected).

dev
frnmst/Franco Masotti 7 years ago
parent
commit
b42604fa92
  1. 0
      icons/gnupotIcon.png
  2. BIN
      icons/gnupotSyncLocal.png
  3. BIN
      icons/gnupotSyncRemote.png
  4. BIN
      icons/gnupotWarning.png
  5. 8
      man/gnupot.config.man
  6. 4
      src/config.sh
  7. 2
      src/configVariables.conf
  8. 3
      src/form.sh
  9. 28
      src/functions.sh

0
src/gnupotIcon.png → icons/gnupotIcon.png

Before

Width:  |  Height:  |  Size: 937 B

After

Width:  |  Height:  |  Size: 937 B

BIN
icons/gnupotSyncLocal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
icons/gnupotSyncRemote.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
icons/gnupotWarning.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

8
man/gnupot.config.man

@ -293,8 +293,12 @@ except that this is the upload speed.
.TP
.B gnupotIcon
.RS
A string containing the full path of GNUpot's icon. This icon will appear on
the desktop notifications.
A string containing the full path of the directory containing GNUpots' icons.
These iconswill appear on the desktop notifications.
.br
The following is a list of all the possible icon names depending from the
action.
TODO
.br
For further information read
.B notify-send\ --help

4
src/config.sh

@ -76,7 +76,7 @@ gnupotGitFileExclude gnupotGitCommitterUsername gnupotGitCommitterEmail \
gnupotTimeToWaitForOtherChanges gnupotBusyWaitTime \
gnupotSSHServerAliveInterval gnupotSSHServerAliveCountMax \
gnupotSSHMasterSocketPath gnupotNotificationTime gnupotLockFilePath \
gnupotDownloadSpeed gnupotUploadSpeed gnupotIcon"
gnupotDownloadSpeed gnupotUploadSpeed gnupotIconsDir"
# Control bash version to avoid IFS bug. bash <=4.2 has this bug. If
# bash is <=4.2 spaces must be avoided in form fields.
@ -239,7 +239,7 @@ gnupotNotificationTime=\""$gnupotNotificationTime"\"\n\
gnupotLockFilePath=\""$gnupotLockFilePath"\"\n\
gnupotDownloadSpeed=\""$gnupotDownloadSpeed"\"\n\
gnupotUploadSpeed=\""$gnupotUploadSpeed"\"\n\
gnupotIcon=\""$gnupotIcon"\"\n\
gnupotIconsDir=\""$gnupotIconsDir"\"\n\
" > "$CONFIGFILEPATH"
chmod 600 "$CONFIGFILEPATH"

2
src/configVariables.conf

@ -51,4 +51,4 @@ gnupotNotificationTime="2000"
gnupotDownloadSpeed="0"
gnupotUploadSpeed="0"
gnupotIcon="$(pwd)/src/gnupotIcon.png"
gnupotIconsDir="$(pwd)/icons"

3
src/form.sh

@ -69,5 +69,6 @@ $action 0 \
20 1 "$gnupotDownloadSpeed" 20 $fldChrs $action 0 \
"Upload max speed (KB/s) (0 = no limit):" \
21 1 "$gnupotUploadSpeed" 21 $fldChrs $action 0 \
"GNUpot icon full path:" 22 1 "$gnupotIcon" 22 $fldChrs $action 0 \
"GNUpot icons directory full path:" 22 1 "$gnupotIconsDir" \
22 $fldChrs $action 0 \
)

28
src/functions.sh

@ -73,7 +73,18 @@ Err() { local msg="$1"; printf "$msg" 1>&2; }
# General notification function.
notify()
{
local msg="$1" ms="$2"
local msg="$1" ms="$2" action="$3"
[ -z "$action" ] && iconPath=""$gnupotIconsDir"/gnupotIcon.png"
[ "$action" = "client" ] && \
iconPath=""$gnupotIconsDir"/gnupotSyncLocal.png"
[ "$action" = "server" ] && \
iconPath=""$gnupotIconsDir"/gnupotSyncRemote.png"
[ "$action" = "warining" ] && \
iconPath=""$gnupotIconsDir"/gnupotWarning.png"
# If you are running GNUpot in a GUI then notify else do nothing.
[ -n "$DISPLAY" ] && notify-send -i "$iconPath" \
@ -168,7 +179,7 @@ LocalDirO SSHKeyPathO RSAKeyBitsU KeepMaxCommitsU InotifyFileExcludeO \
GitFileExcludeO GitCommitterUsernameO GitCommitterEmailO \
TimeToWaitForOtherChangesU BusyWaitTimeU SSHServerAliveIntervalN \
SSHServerAliveCountMaxN SSHMasterSocketPathO NotificationTimeU LockFilePathO \
DownloadSpeedU UploadSpeedU IconO"
DownloadSpeedU UploadSpeedU IconsDirO"
local variable="" type=""
for variable in $variableList; do
@ -245,7 +256,7 @@ DirErr()
exist, or no git repository."
Err "$errMsg\n"
notify "$errMsg" "$gnupotNotificationTime"
notify "$errMsg" "$gnupotNotificationTime" "warning"
kill -s SIGINT 0
}
@ -275,7 +286,7 @@ busyWait()
busyWaitAcquireLockFile
notify "Connection or auth problem. Retrying in \
"$gnupotBusyWaitTime" seconds..." "$gnupotNotificationTime"
"$gnupotBusyWaitTime" seconds..." "$gnupotNotificationTime" "warning"
sleep "$gnupotBusyWaitTime"
updateDNSRecord
# Restore previous state in lock file.
@ -343,7 +354,7 @@ resolveConflicts()
local returnedVal="$1" path="$2"
[ "$returnedVal" -eq 1 ] \
&& { notify "Resolving file conflicts." "$gnupotNotificationTime"; \
&& { notify "Resolving file conflicts." "$gnupotNotificationTime" "warning"; \
git commit -a -m "Committed "$path" $USERDATA Handled conflicts"; }
}
@ -389,7 +400,7 @@ syncOperation()
local source="$1" path="$2"
sleep "$gnupotTimeToWaitForOtherChanges"
notify "Syncing $path from $source" "$gnupotNotificationTime"
notify "Syncing $path from $source" "$gnupotNotificationTime" "$source"
# Do all git operations in the correct directory before returning.
# The compressed (list) vewrsion of this didn't work. It also made a
# double, unexplicable call to gitSyncOperations
@ -599,11 +610,6 @@ parseOpts()
{
local prgPath="$1" argArray="$2"
# NOTE: notify-send works only with full paths. Variable setting here must
# changed, otherwise it cannot be handled in the PKGBUILD. It can be set in
# the setup so it's simpler...
iconPath="$gnupotIcon"
# Get options from special variable $@. Treat no arguments as -i.
getopts ":dhknpsv" opt "$argArray"
case "$opt" in