Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iml-backup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
iml-backup
Commits
7efe01f8
Commit
7efe01f8
authored
2 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
add function for desktop notification
parent
a6465e40
Branches
Branches containing commit
No related tags found
1 merge request
!101
Desktop notification
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
jobhelper.sh
+29
-0
29 additions, 0 deletions
jobhelper.sh
with
29 additions
and
0 deletions
jobhelper.sh
+
29
−
0
View file @
7efe01f8
...
...
@@ -82,6 +82,11 @@ function j_init(){
j_requireBinary
"tee"
j_requireBinary
"touch"
# for notify-send in j_notify()
if
[
-n
"
$SUDO_USER
"
]
;
then
export
DBUS_SESSION_BUS_ADDRESS
=
unix:path
=
/run/user/
$(
id
-u
$SUDO_USER
)
/bus
fi
# j_read
}
...
...
@@ -419,6 +424,30 @@ function _getFqdn(){
# echo "INFO: FQDN is [$FQDN]"
}
# show a desktop notification using notify-send
# param string summary (aka title)
# param string message text
# paran integer optional: exitcode; if set it adds a prefix OK or ERRROR on summary and sets urgency on error
function
j_notify
(){
local
_summary
=
"IML BACKUP ::
$1
"
local
_body
=
"
$2
"
local
_rc
=
"
$3
"
local
_urgency
=
"normal"
if
[
-n
"
$DBUS_SESSION_BUS_ADDRESS
"
]
;
then
if
[
-n
"
$_rc
"
]
;
then
if
[
"
$_rc
"
=
"0"
]
;
then
_summary
=
"OK:
${
_summary
}
"
else
_summary
=
"ERROR:
${
_summary
}
"
_urgency
=
"critical"
fi
fi
su
"
$SUDO_USER
"
-c
"notify-send --urgency=
${
_urgency
}
'
${
_summary
}
' '
${
_body
}
'"
fi
}
# ------------------------------------------------------------
# check if it was startet with a given user
# This is skipped if MS windows was detected with "mingw".
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment