{"id":386803,"date":"2024-11-28T13:25:06","date_gmt":"2024-11-28T13:25:06","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=386803"},"modified":"2024-11-28T13:25:06","modified_gmt":"2024-11-28T13:25:06","slug":"effektive-popup-meldungen-unter-linux","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/de\/script-hub\/effektive-popup-meldungen-unter-linux\/","title":{"rendered":"Guide f\u00fcr IT-Experten und MSPs: Wie man effektive Popup-Meldungen unter Linux erstellen kann"},"content":{"rendered":"<p>Effiziente Kommunikation ist f\u00fcr IT-Experten von entscheidender Bedeutung, insbesondere bei der Verwaltung mehrerer Systeme und Benutzer:innen. Eine h\u00e4ufige Anforderung ist das Versenden von Benachrichtigungen oder Erinnerungen an Benutzer:innen \u00fcber Systemaktualisierungen, Wartungsarbeiten oder andere kritische Aktionen. In diesem Blogbeitrag wird ein vielseitiges Bash-Skript vorgestellt, mit dem man <strong>effektive Popup-Meldungen unter Linux<\/strong> erstellen kann. Dieses Tool kommt besonders IT-Administratoren und <a href=\"https:\/\/www.ninjaone.com\/what-is-an-msp\/\" target=\"_blank\" rel=\"noopener\">Managed Service Providern (MSPs)<\/a> zugute.<\/p>\n<h2>Kontext<\/h2>\n<p>In der dynamischen Welt der IT kann eine rechtzeitige Kommunikation Datenverluste verhindern und sicherstellen, dass die Benutzer:innen gut \u00fcber die Systemaktivit\u00e4ten informiert sind. Das Bash-Skript, das wir heute besprechen, ist auf Linux-Umgebungen zugeschnitten und mit X11 KDE- und X11 Gnome-Desktops kompatibel. Dieses Skript sendet nicht nur Nachrichten an alle angeschlossenen Endpunkte, sondern erzeugt auch ein visuelles Popup-Fenster auf dem Bildschirm der Benutzer:innen, das daf\u00fcr sorgt, dass wichtige Benachrichtigungen sofort gesehen werden.<\/p>\n<h2>Das Skript f\u00fcr effektive Popup-Meldungen unter Linux<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">#!\/usr\/bin\/env bash\r\n#\r\n# Description: Outputs messages on all connected terminals and creates a popup window on the end-user's screen. The popup requires ImageMagick and supports X11 KDE &amp; X11 Gnome environments; other environments will only display the terminal message. Use the \"Restart Reminder\" feature to trigger a generic restart prompt.\r\n# By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n# Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n# Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n# Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n# Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n# Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n# Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n# EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#\r\n# Preset Parameter: --restartreminder\r\n#   Displays a generic restart PopUp. Can be overridden with parameters. Equivalent to the below parameters.\r\n#   --title 'NinjaOne Rmm'\r\n#   --message 'Your IT Administrator has scheduled a restart of your computer in the next 15 minutes. Please save your work as soon as possible to prevent data loss.'\r\n#   --timeoutaction 'shutdown -r'\r\n#\r\n# Preset Parameter: --title 'ReplaceWithYourDesiredHeader'\r\n#   Replace the text encased in quotes to replace the text in the title bar of the popup window (defaults to 'NinjaOne RMM').\r\n#\r\n# Preset Parameter: --message 'ReplaceWithYourPopUpMessage'\r\n#   Replace the text encased in quotes to put some text inside of the PopUp Window.\r\n#\r\n# Preset Parameter: --iconpath 'A URL or \/a\/path\/to\/an\/image.png'\r\n#   Replace the text encased in quotes with either a url to an image or a filepath to an icon. The script uses the NinjaOne Logo by default.\r\n#   For best results use a 128px x 128px png. Though other formats and sizes will work.\r\n#   Highly recommend keeping a 1:1 ratio for the width and height.\r\n#   Supported formats: png, jpg, jpeg, webp, bmp, ico and gif (will not be animated in popup)\r\n#   If you have a base64 encoding of your image you could also replace the default base64 on line 37.\r\n#\r\n# Preset Parameter: --timeout 'ReplaceWithAnumberofSeconds'\r\n#   Replace the text encased in quotes with the number of seconds you'd like the PopUp to display for.\r\n#\r\n# Preset Parameter: --okbuttonaction 'ReplaceWithYourDesiredAction(Executes in Bash)'\r\n#   Replace the text encased in quotes with the command you'd like to run when the left button is clicked by the user (executes in bash).\r\n#\r\n# Preset Parameter: --exitbuttonaction 'ReplaceWithYourDesiredAction(Executes in Bash)'\r\n#   Replace the text encased in quotes with the command you'd like to run when the popup window is closed (executes in bash).\r\n#\r\n# Preset Parameter: --timeoutaction 'ReplaceWithYourDesiredAction(Executes in Bash)'\r\n#   Replace the text encased in quotes with the command you'd like to run when the dialog box times out (executes in bash).\r\n\r\n# You can replace the below line with iconbase64='ReplaceThisWithYourBase64encodedimageEncasedInQuotes' and the script will decode the image and use it in the popup window.\r\niconbase64='iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAAJFBMVEUARF0Apc0AmL8ApM0Aos0Aps7\/\/\/8Am8ia1ug9rtLd8\/jw+\/2tMDHwAAAABXRSTlMBrBTIcce4nvwAAAIeSURBVHic7dvrcoMgEAXgiOAivv\/7Fm+JBpCLwk7bsz86rcNkPw+Y0Gl5vd4lGtbLKSG7vmF18mwQnWpe3YcghP2Z1svU8OtbIOihm8op25M2gWBov9UqYJj\/vSRzAGsEkhMglxngWINbdbxLAAAAAAAAAAAAAKAI8Oz2KRtApPWThEyAbT8NZwDZGpeav6sLIKXNMBwAtuGotTGTvTpMRms9qkxEBsDe\/dz+A7B3rufeS\/utrCKPkAywzfYmK8BeOHY+lBkzBImALfwDgA4XnNLphCTA4e43AKmL9vNMJD8pCQAna20nP5D+SfkQgJyp1qS9PYsEKQDnpVP627WYJCgBmGj+GRmUAFIraSXWBAwDcwJJk1AXMIzcgHgElQHxCGoDohHcBsybgIvPpei70S2A0csuaNkTBRBTbA7uAOb271E0+gWxOSgHfG87yD+wGsCz7fGONNf9iwGTb89DnlkwkUVQCPD2t1sXz9A6gMDT5YsgsggKARljI\/vTMkDo7cU3B1USCL+oOwdVAMGF5RlcAxB+tBoBwq\/JDlDcAPYEAGgDuPiNBwkgASSABJAAEkACSAAJIAEkgASQABL4JwlcA9w\/9N4GTOZcl1OQMTgRoEannhv9O\/+PCAAAAAAAAAAAAACAPwhgP+7HeOCR1jOfjBHI9dBrz9W\/34\/d9jyHLvvPweP2GdCx\/3zyvLlAfZ8+l13LktJzAJ+nfgAP50EVLvPsRgAAAABJRU5ErkJggg=='\r\nworkingdir=\"\/tmp\/ninjaone-rmm-popup\"\r\n\r\ndie() {\r\n    local _ret=\"${2:-1}\"\r\n    test \"${_PRINT_HELP:-no}\" = yes &amp;&amp; print_help &gt;&amp;2\r\n    echo \"$1\" &gt;&amp;2\r\n    exit \"${_ret}\"\r\n}\r\n\r\n# THE DEFAULTS INITIALIZATION - OPTIONALS\r\n_arg_title=\"NinjaOne RMM\"\r\n_arg_message=\r\n_arg_iconpath=\r\n_arg_obuttonaction=\r\n_arg_ebuttonaction=\r\n_arg_timeoutaction=\r\n_arg_timeout=900\r\n_arg_restartreminder=\"off\"\r\n\r\n# The function will print out some help text if the user entered in something wrong\r\nprint_help() {\r\n    printf '\\t%s\\n\\n' 'Usage: [-t|--title &lt;arg&gt;] [-m|-msg|--message &lt;arg&gt;] [-i|-icon|--iconpath &lt;arg&gt;] [-ea | -ebtnact | -extbtnaction | --exitbuttonaction &lt;arg&gt;] [-oa | -okbtnact | -okbtnaction | --okbuttonaction &lt;arg&gt;] [-to | --timeout &lt;arg&gt;] [-toa | -toact| --timeoutaction &lt;arg&gt;] [ -restart | --restartreminder] [-h|--help]'\r\n    printf '%s\\n' \"Preset Parameter: --restartreminder\"\r\n    printf '\\t%s\\n' \"Displays a generic restart PopUp. Can be overridden with parameters. Equivelant to the below parameters.\"\r\n    printf '\\t%s\\n' \"--title 'NinjaOne Rmm'\"\r\n    printf '\\t%s\\n' \"--message 'Your IT Administrator has scheduled a restart of your computer in the next 15 minutes. Please save your work as soon as possible to prevent data loss.'\"\r\n    printf '\\t%s\\n' \"--timeoutaction 'shutdown -r'\"\r\n    printf '%s\\n' \"Preset Parameter: --title 'ReplaceWithYourDesiredHeader'\"\r\n    printf '\\t%s\\n' \"Replace the text encased in quotes to replace the text in the title bar of the popup window (defaults to 'NinjaOne RMM')\"\r\n    printf '%s\\n' \"Preset Parameter: --message 'ReplaceWithYourPopUpMessage'\"\r\n    printf '\\t%s\\n' \"Replace the text encased in quotes to put some text inside of the PopUp Window\"\r\n    printf '%s\\n' \"Preset Parameter: --iconpath 'A URL or \/a\/path\/to\/an\/image.png'\"\r\n    printf '\\t%s\\n' \"Replace the text encased in quotes with either a url to an image or a filepath to an icon. The script uses the NinjaOne Logo by default.\"\r\n    printf '%s\\n' \"Preset Parameter: --timeout 'ReplaceWithAnumberofSeconds'\"\r\n    printf '\\t%s\\n' \"Replace the text encased in quotes with the number of seconds you'd like the PopUp to display for.\"\r\n    printf '%s\\n' \"Preset Parameter: --okbuttonaction 'ReplaceWithYourDesiredAction(Executes in Bash)'\"\r\n    printf '\\t%s\\n' \"Replace the text encased in quotes with the command you'd like to run when the ok button is clicked by the user (executes in bash).\"\r\n    printf '%s\\n' \"Preset Parameter: --exitbuttonaction 'ReplaceWithYourDesiredAction(Executes in Bash)'\"\r\n    printf '\\t%s\\n' \"Replace the text encased in quotes with the command you'd like to run when the user closes the dialog (executes in bash).\"\r\n    printf '%s\\n' \"Preset Parameter: --timeoutaction 'ReplaceWithYourDesiredAction(Executes in Bash)'\"\r\n    printf '\\t%s\\n' \"Replace the text encased in quotes with the command you'd like to run when the dialog box times out (executes in bash).\"\r\n}\r\n\r\n# decipher's the parameters given and stores them as variables\r\nparse_commandline() {\r\n    while test $# -gt 0; do\r\n        _key=\"$1\"\r\n        case \"$_key\" in\r\n        -t | --title)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_title=\"$2\"\r\n            shift\r\n            ;;\r\n        --title=*)\r\n            _arg_title=\"${_key##--title=}\"\r\n            ;;\r\n        -m | -msg | --message)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_message=\"$2\"\r\n            shift\r\n            ;;\r\n        --message=*)\r\n            _arg_message=\"${_key##--message=}\"\r\n            ;;\r\n        --msg=*)\r\n            _arg_message=\"${_key##--msg=}\"\r\n            ;;\r\n        -i | -icon | --iconpath)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_iconpath=\"$2\"\r\n            shift\r\n            ;;\r\n        --iconpath=*)\r\n            _arg_iconpath=\"${_key##--iconpath=}\"\r\n            ;;\r\n        --icon=*)\r\n            _arg_iconpath=\"${_key##--icon=}\"\r\n            ;;\r\n        -ea | -ebtnact | -extbtnaction | --exitbuttonaction)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_ebuttonaction=\"$2\"\r\n            shift\r\n            ;;\r\n        --exitbuttonaction=*)\r\n            _arg_ebuttonaction=\"${_key##--ebuttonaction=}\"\r\n            ;;\r\n        -oa | -okbtnact | -okbtnaction | --okbuttonaction)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_obuttonaction=\"$2\"\r\n            shift\r\n            ;;\r\n        --okbuttonaction=*)\r\n            _arg_obuttonaction=\"${_key##--obuttonaction=}\"\r\n            ;;\r\n        -to | --timeout)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_timeout=\"$2\"\r\n            shift\r\n            ;;\r\n        --timeout=*)\r\n            _arg_timeout=\"${_key##--timeout=}\"\r\n            ;;\r\n        -toa | -toact | --timeoutaction)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_timeoutaction=\"$2\"\r\n            shift\r\n            ;;\r\n        --timeoutaction=*)\r\n            _arg_timeoutaction=\"${_key##--timeoutaction=}\"\r\n            ;;\r\n        -restart | --restartreminder)\r\n            _arg_restartreminder=\"on\"\r\n            ;;\r\n        -h | --help)\r\n            print_help\r\n            exit 0\r\n            ;;\r\n        -h*)\r\n            print_help\r\n            exit 0\r\n            ;;\r\n        *)\r\n            _PRINT_HELP=yes die \"FATAL ERROR: Got an unexpected argument '$1'\" 1\r\n            ;;\r\n        esac\r\n        shift\r\n    done\r\n}\r\n\r\n# Initializes parameter processing\r\nparse_commandline \"$@\"\r\n\r\nif [[ -n $title ]]; then\r\n    _arg_title=$title\r\nfi\r\n\r\nif [[ -n $message ]]; then\r\n    _arg_message=$message\r\nfi\r\n\r\nif [[ -n $iconPath ]]; then\r\n    _arg_iconpath=$iconPath\r\nfi\r\n\r\nif [[ -n $timeout ]]; then\r\n    _arg_timeout=$timeout\r\nfi\r\n\r\nif [[ -n $timeoutAction ]]; then\r\n    _arg_timeoutaction=$timeoutAction\r\nfi\r\n\r\nif [[ -n $okButtonAction ]]; then\r\n    _arg_obuttonaction=$okButtonAction\r\nfi\r\n\r\nif [[ -n $exitButtonAction ]]; then\r\n    _arg_ebuttonaction=$exitButtonAction\r\nfi\r\n\r\nif [[ -n $restartReminder &amp;&amp; $restartReminder == \"true\" ]]; then\r\n    _arg_restartreminder=\"on\"\r\nfi\r\n\r\n# If --restartreminder was selected we'll want to preset some of the parameters\r\nif [[ $_arg_restartreminder == \"on\" ]]; then\r\n    if [[ -z $_arg_message ]]; then\r\n        _arg_message=\"Your IT Administrator has scheduled a restart of your computer in the next 15 minutes. Please save your work as soon as possible to prevent data loss.\"\r\n    fi\r\n\r\n    if [[ -z $_arg_timeoutaction ]]; then\r\n        _arg_timeoutaction='shutdown -r'\r\n    fi\r\nfi\r\n\r\n# Grabbing information about the current setup\r\nactiveUsers=$(loginctl list-sessions | grep seat | sed 's\/[0-9]\\+\/\/g' | sed 's\/seat\/\/g' | sed 's\/tty\/\/g' | xargs)\r\nactiveDisplay=$(w -oush | grep -Eo ' :[0-9]+' | uniq | head -1 | xargs)\r\nGNOME=$(command -v zenity)\r\nKDE=$(command -v kdialog)\r\nimageMagick=$(command -v convert)\r\n\r\n# Must give a number\r\npattern='^[0-9]+$'\r\nif [[ ! $_arg_timeout =~ $pattern ]]; then\r\n    _PRINT_HELP=no die \"FATAL ERROR: --timeout requires a number of seconds in order to work. ex. '60' for 60 seconds.\" 1\r\nfi\r\n\r\n# No matter what we're going to send a message to all connected terminals\r\necho \"Sending message to all connected terminals.\"\r\nwall \"$_arg_message\"\r\nif [[ -z $imageMagick ]]; then\r\n    echo \"WARNING: Image Magick is not installed. This script will be unable to display a popup without it. This script will still be able to send a message to all ssh connected terminals.\"\r\nfi\r\n\r\n# If not on a supported desktop environment or simply nobodies logged in skip this whole block.\r\nif [[ (-n $GNOME || -n $KDE) &amp;&amp; -n $activeDisplay &amp;&amp; -n $activeUsers &amp;&amp; -n $imageMagick ]]; then\r\n    # Create's a working directory if it doesn't already exist\r\n    if [[ ! -d \"$workingdir\" ]]; then\r\n        mkdir $workingdir\r\n    fi\r\n\r\n    # If given a url attempt to download the image file\r\n    pattern=\"https?:\/\/.*\"\r\n    if [[ $_arg_iconpath =~ $pattern ]]; then\r\n        wget -q \"$_arg_iconpath\" -O \"$workingdir\/downloadedimg\" -t 7 --random-wait\r\n        _arg_iconpath=$workingdir\/downloadedimg\r\n    fi\r\n\r\n    # If a base64 icon is provided and no other iconpath was specified use that.\r\n    if [[ -n $iconbase64 &amp;&amp; -z $_arg_iconpath ]]; then\r\n        base64 -d &lt;&lt;&lt;$iconbase64 &gt;$workingdir\/base64img\r\n        _arg_iconpath=$workingdir\/base64img\r\n    # If an iconpath was provided copy it to the working directory\r\n    elif [[ ! $_arg_iconpath == \"$workingdir\/downloadedimg\" ]]; then\r\n        cp \"$_arg_iconpath\" \"$workingdir\/downloadedimg\"\r\n        _arg_iconpath=\"$workingdir\/downloadedimg\"\r\n    fi\r\n\r\n    # Dobule check that we were given an image and find it's extension\r\n    mimetype=$(file --mime-type -b \"$_arg_iconpath\" | grep \"image\")\r\n    extension=$(file --extension -b \"$_arg_iconpath\" | sed 's\/\\\/.*\/\/g')\r\n\r\n    # If the mimetype indicates its not an image error out\r\n    if [[ -z $mimetype ]]; then\r\n        _PRINT_HELP=no die \"FATAL ERROR: No image found!\" 1\r\n    # If it's not a png we'll need to convert it to one and it'll need to be 128x128.\r\n    elif [[ ! $extension == \"png\" ]]; then\r\n        cp \"$_arg_iconpath\" \"$workingdir\/img.$extension\"\r\n        convert -resize 128x128! -background none -coalesce \"$workingdir\/img.$extension\" \"$workingdir\/img.png\"\r\n        # Some image types ex. .ico files will have multiple pngs embeded in it. This ensures only one is selected.\r\n        _arg_iconpath=$(find $workingdir\/img*.png | tail -1)\r\n    fi\r\n\r\n    # If post conversion we don't have an image we can use error out\r\n    if [[ -n $_arg_iconpath ]]; then\r\n        mv \"$_arg_iconpath\" \"$workingdir\/$_arg_title.png\"\r\n        convert \"$workingdir\/$_arg_title.png\" -resize 128x128! \"\/usr\/share\/pixmaps\/$_arg_title.png\"\r\n        _arg_iconpath=\"\/usr\/share\/pixmaps\/$_arg_title.png\"\r\n    else\r\n        _PRINT_HELP=no die \"FATAL ERROR: Image missing after converting to png?\" 1\r\n    fi\r\n\r\n    # If using the Gnome Desktop enviornment we'll need to use zenity otherwise we can use kdialog.\r\n    if [[ -n $GNOME ]]; then\r\n        export DISPLAY=\"$activeDisplay\"\r\n        for user in $activeUsers; do\r\n            popup=$(\r\n                $popup\r\n                su \"$user\" -c 'xhost local:'\"$user\"'; zenity --window-icon \"'\"$_arg_iconpath\"'\" --title \"'\"$_arg_title\"'\" --icon-name \"'\"$_arg_title\"'\" --info --text \"'\"$_arg_message\"'\" --timeout \"'\"$_arg_timeout\"'\"'\r\n                echo -e \"\\n$?\"\r\n            )\r\n        done\r\n    elif [[ -n $KDE ]]; then\r\n        export DISPLAY=\"$activeDisplay\"\r\n        for user in $activeUsers; do\r\n            popup=$(\r\n                $popup\r\n                # kdialog doesn't seem to have an option for an actual dialog to time out so we'll make a popup message instead\r\n                su \"$user\" -c 'xhost local:'\"$user\"'; kdialog --icon \"'\"$_arg_iconpath\"'\" --title \"'\"$_arg_title\"'\" --passivepopup \"'\"$_arg_message\"'\" '\"$_arg_timeout\"''\r\n                echo -e \"\\n$?\"\r\n            )\r\n        done\r\n    fi\r\n\r\n    # This grabs the exitcode for each time the dialog was ran\r\n    results=$(echo \"$popup\" | grep -Eo '[0-9]')\r\n    for result in $results; do\r\n        if [[ $result == -1 || $result == 254 ]]; then\r\n            _PRINT_HELP=no die \"FATAL ERROR: Unable to display popup?\" 1\r\n        fi\r\n\r\n        # Kdialog will give an exit code of 2 when exiting while Gnome will give an exit code of 1\r\n        if [[ -n $_arg_ebuttonaction &amp;&amp; ($result == 1 || $result == 2) ]]; then\r\n            echo \"Exit Button Clicked\"\r\n            eval \"$_arg_ebuttonaction\"\r\n        elif [[ $result == 1 || $result == 2 ]]; then\r\n            echo \"Exit Button Clicked\"\r\n        fi\r\n\r\n        if [[ -n $_arg_obuttonaction &amp;&amp; $result == 0 &amp;&amp; -n $GNOME ]]; then\r\n            echo \"OK Button Clicked\"\r\n            eval \"$_arg_obuttonaction\"\r\n        elif [[ $result == 0 &amp;&amp; -n $GNOME ]]; then\r\n            echo \"OK Button Clicked\"\r\n        fi\r\n\r\n        if [[ -n $_arg_timeoutaction &amp;&amp; $result == 5 || (-n $KDE &amp;&amp; $result == 0) ]]; then\r\n            echo \"Pop-up has timed out! Executing timeout action....\"\r\n            eval \"$_arg_timeoutaction\"\r\n        elif [[ $result == 5 || (-n $KDE &amp;&amp; $result == 0) ]]; then\r\n            echo \"Pop-up has timed out!\"\r\n        fi\r\n    done\r\n\r\n    # Removes the old icon\r\n    rm \"$_arg_iconpath\"\r\nelse\r\n    echo \"No active X11 displays using GNOME or KDE were found. This script will display a terminal message only.\"\r\n    if [[ ! $_arg_timeout == 0 ]]; then\r\n        echo \"Sleeping for $_arg_timeout seconds...\"\r\n        sleep \"$_arg_timeout\"\r\n    fi\r\n    if [[ -n $_arg_timeoutaction ]]; then\r\n        echo \"Executing timeout action.\"\r\n        eval \"$_arg_timeoutaction\"\r\n    fi\r\nfi<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Greifen Sie auf \u00fcber 300 Skripte im NinjaOne Dojo zu.<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Zugang erhalten<\/a><\/p>\n<\/div>\n<h2>Detailansicht<\/h2>\n<p>Das Skript wurde mit Blick auf Flexibilit\u00e4t entwickelt und bietet verschiedene Parameter zur Anpassung der Popup-Meldungen. Im Folgenden wird Schritt f\u00fcr Schritt erkl\u00e4rt, wie es funktioniert:<\/p>\n<ol>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Initialisierung und Hilfefunktion<\/strong>: Das Skript beginnt mit der Definition von Standardwerten f\u00fcr verschiedene Parameter, z. B. f\u00fcr den Titel, die Meldung, den Symbolpfad, die Timeout-Dauer und die Aktionen f\u00fcr die Schaltfl\u00e4chen &#8218;OK&#8216; und &#8218;Beenden&#8216;. Es enth\u00e4lt auch eine Hilfefunktion, die den Benutzer:innen zeigt, wie sie das Skript effektiv verwenden k\u00f6nnen.<\/li>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Parameter-Parsen<\/strong>: Die Funktion &#8218;parse_commandline&#8216; verarbeitet die Eingabeargumente und erm\u00f6glicht es den Benutzer:innen, die Standardwerte zu \u00fcberschreiben. Parameter sind &#8211;title, &#8211;message, &#8211;iconpath, &#8211;timeout, &#8211;okbuttonaction, &#8211;exitbuttonaction und &#8211;timeoutaction.<\/li>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Einrichtung der Umgebung<\/strong>: Das Skript \u00fcberpr\u00fcft die aktuelle Konfiguration, um aktive Benutzer:innen zu ermitteln und Umgebungen anzuzeigen. Es unterst\u00fctzt sowohl Gnome- als auch KDE-Desktops und nutzt Tools wie &#8218;zenity&#8216; und &#8218;kdialog&#8216; zur Erstellung von Popup-Meldungen.<\/li>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Handhabung von Symbolen<\/strong>: Wenn eine Symbol-URL angegeben wird, l\u00e4dt das Skript das Bild herunter. Es unterst\u00fctzt auch base64-kodierte Bilder, die dekodiert und im Popup verwendet werden k\u00f6nnen. Das Skript sorgt daf\u00fcr, dass das Bild im PNG-Format vorliegt und \u00e4ndert die Gr\u00f6\u00dfe gegebenenfalls auf 128&#215;128 Pixel.<\/li>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Erstellung des Popups<\/strong>: Je nach Desktop-Umgebung verwendet das Skript &#8218;zenity&#8216; oder &#8218;kdialog&#8216;, um die Popup-Meldung anzuzeigen. Es verarbeitet verschiedene Aktionen auf der Grundlage von Benutzerinteraktionen, wie z. B. das Klicken auf die Schaltfl\u00e4chen &#8218;Ok&#8216; oder &#8218;Beenden&#8216;, oder wenn das Popup eine Zeit\u00fcberschreitung aufweist.<\/li>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Fallback f\u00fcr Endpunkt-Nachrichten<\/strong>: Wenn keine geeignete Desktop-Umgebung gefunden wird, sendet das Skript Nachrichten an alle angeschlossenen Endpunkte, um sicherzustellen, dass die Benachrichtigung trotzdem \u00fcbermittelt wird.<\/li>\n<\/ol>\n<h2>Potenzielle Anwendungsf\u00e4lle<\/h2>\n<p>Stellen Sie sich einen IT-Experten vor, der ein Computernetzwerk in einer Unternehmensumgebung verwaltet. Aufgrund eines kritischen Updates m\u00fcssen dringend mehrere Rechner neu gestartet werden. Mit diesem Skript kann der IT-Administrator eine Popup-Meldung an alle Benutzer senden, um sie \u00fcber den bevorstehenden Neustart zu informieren und sie aufzufordern, ihre Arbeit zu speichern. Dadurch wird sichergestellt, dass die Benutzer:innen \u00fcber die Ma\u00dfnahme informiert sind und sich entsprechend vorbereiten k\u00f6nnen, um St\u00f6rungen und Datenverluste zu minimieren.<\/p>\n<h2>Vergleiche<\/h2>\n<p>Andere Methoden zur Benachrichtigung der Anwender:innen sind E-Mail-Benachrichtigungen, Chat-Nachrichten oder sogar Telefonanrufe. Diese Methoden sind jedoch m\u00f6glicherweise nicht so schnell und auff\u00e4llig wie eine Popup-Meldung direkt auf dem Bildschirm der Benutzer:innen. Dieses Skript bietet eine direkte und unumg\u00e4ngliche Benachrichtigungsmethode, die daf\u00fcr sorgt, dass wichtige Nachrichten sofort gesehen werden.<\/p>\n<h2>FAQs<\/h2>\n<h3>1) Wie kann ich die Popup-Meldung anpassen?<\/h3>\n<p>Sie k\u00f6nnen die Nachricht anpassen, indem Sie den Parameter &#8218;&#8211;message&#8216; gefolgt von dem gew\u00fcnschten Text verwenden.<\/p>\n<h3>2) Kann ich ein Bild in dem Popup verwenden?<\/h3>\n<p>Ja, Sie k\u00f6nnen eine Bild-URL oder einen Dateipfad mit dem Parameter &#8211;iconpath angeben.<\/p>\n<h3>3) Was passiert, wenn das Skript auf einem System ohne GNOME oder KDE l\u00e4uft?<\/h3>\n<p>Das Skript sendet weiterhin Nachrichten an alle angeschlossenen Endpunkte, erstellt aber kein Popup-Fenster.<\/p>\n<h3>4) Wie kann ich die Anzeigedauer des Popups festlegen?<\/h3>\n<p>Verwenden Sie den Parameter &#8211;timeout, gefolgt von der Anzahl der Sekunden, die das Popup angezeigt werden soll.<\/p>\n<h3>5) Ist es m\u00f6glich, einen Befehl auszuf\u00fchren, wenn das Popup-Fenster nicht mehr angezeigt wird?<\/h3>\n<p>Ja, mit dem Parameter &#8211;timeoutaction k\u00f6nnen Sie einen Befehl angeben, der bei Zeit\u00fcberschreitung ausgef\u00fchrt wird.<\/p>\n<h2>Folgen<\/h2>\n<p>Die Verwendung dieses Skripts erh\u00f6ht die IT-Sicherheit, da es sicherstellt, dass kritische Benachrichtigungen nicht \u00fcbersehen werden. Egal, ob es sich um einen Systemneustart, eine Wartungserinnerung oder eine Sicherheitswarnung handelt, das Skript garantiert, dass die Benutzer:innen umgehend informiert werden, wodurch das Risiko von Datenverlusten verringert und die Systemintegrit\u00e4t gew\u00e4hrleistet wird.<\/p>\n<h2>Empfehlungen<\/h2>\n<p>Wenn Sie dieses Skript verwenden, ist es wichtig, dass Sie:<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\">das Skript in einer Staging-Umgebung testen, bevor Sie es skaliert verteilen.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\">sicherstellen, dass ImageMagick installiert ist, um Bilder verarbeiten zu k\u00f6nnen.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">die Parameter an die spezifischen Anforderungen Ihres Unternehmens anpassen.<\/li>\n<\/ul>\n<h2>Abschlie\u00dfende \u00dcberlegungen<\/h2>\n<p>Wirksame Kommunikationsmittel sind f\u00fcr das IT-Management unerl\u00e4sslich. Dieses Bash-Skript bietet eine zuverl\u00e4ssige M\u00f6glichkeit, Popup-Meldungen an Linux-Benutzer:innen zu senden, um zu gew\u00e4hrleisten, dass wichtige Benachrichtigungen gesehen und befolgt werden. F\u00fcr IT-Experten und MSPs sind solche Tools von unsch\u00e4tzbarem Wert, wenn es darum geht, die Systemintegrit\u00e4t aufrechtzuerhalten und f\u00fcr die Durchf\u00fchrung wichtiger Aktualisierungen und Ma\u00dfnahmen durch die Benutzer:innen zu sorgen.<\/p>\n","protected":false},"author":35,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4211],"use_cases":[4307],"class_list":["post-386803","script_hub","type-script_hub","status-publish","hentry","script_hub_category-linux","use_cases-allgemeine-konfiguration"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub\/386803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/comments?post=386803"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/media?parent=386803"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/operating_system?post=386803"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/use_cases?post=386803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}