How to have system notifications in antiX without using system resources

Forum Forums General Software How to have system notifications in antiX without using system resources

  • This topic has 8 replies, 4 voices, and was last updated Jan 19-8:00 pm by Anonymous.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #50091
    Member
    PPC

      How to have system notifications in antiX without using system resources (no Deamons running in RAM)

      This guide uses Herbe to show system notifications, and was inspired by the thread “Herbe (notifications)”
      System notifications are a handy way to inform you when you get new e-mail messages, are low on the laptop battery, etc.
      Because usually system notifications require a demon to be running, using RAM, antiX does not provide them out of the box (but you can install “Dunst” from package installer, that uses about 7 Mb of your RAM, if you want to).

      1- Pre-requeriments (this takes probably about 20 Mb of disk space):
      To ensure you can use Herbe (available in http://github.com/dudik/herbe/), run this command in the terminal [enter your password if asked to):

      sudo apt install git libx11-dev libxft-dev

      2- “Installing” Herbe- in the terminal run this commands (it’s way less than 1 Mb of disk space):

      
         cd
         git clone http://github.com/dudik/herbe
         cd ~/herbe
         cp config.def.h config.h
         make

      This will compile a “herbe” binary file in the sub-folder “herbe”, inside your Home folder

      3- Optional step: Backup notify-send in your system, to be on the safe side:

      sudo cp /usr/bin/notify-send /usr/bin/notify-send.BAK

      4- Download this script ( and by that I mean: copy the text from this webpage to an empty text file, save it to your ~/herbe folder as “notify-send” and make sure that the file executable)
      http://raw.githubusercontent.com/dudik/herbe/24557245869662e1885f286037ecc37038a5f791/notify-send

      5- Alter this file to use your “herbe” command: by changing it’s last line and replacing

      herbe "$@" &

      with

      ~/herbe/herbe "$@" &

      5.2- Optional step: if you want to have a log file of all your system notifications (going back to the last 20 notifications), add this new lines to the “notify-send” file, after the last line:

      #####to always have a log of only the last 20 lines:
      timestamp=$(date)
      echo $timestamp – “$@” >> ~/.config/notifications_log.txt &
      tail -20 ~/.config/notifications_log.txt > /tmp/temporary_file.txt && cp /tmp/temporary_file.txt ~/.config/notifications_log.txt

      You can view/edit the notifications log doing this, from the terminal (or clicking the ~/.config/notifications_log.txt using your file manager):

      geany ~/.config/notifications_log.txt

      6- Replace the original “notify-send” file in your system with this new one:

      sudo cp ~/herbe/notify-send /usr/bin/notify-send

      You now have system notifications available.
      You can test notifications running this command:
      notify-send " Hello world "
      This will create a notification on the upper right corner of your screen. If that shows up, the process is finished. If not, something went wrong… 🙁

      _____________________________

      Why compile the herbe executable inside your Home folder, instead of installing it system wide?
      Easy: this allows you to toggle notifications on and off without needing administration privileges (sudo)

      To toggle notifications off:

      notify-send "System notifications will be disabled" && mv ~/herbe/herbe ~/herbe/herbe.off

      To toogle notifications back on:

      mv ~/herbe/herbe.off ~/herbe/herbe && notify-send "System notifications are now enabled"

      Editing herbe’s configuration (fonts, etc): run this command from the terminal:

      cd ~/herbe && mv ~/herbe/herbe ~/herbe/herbe.off && geany ~/herbe/config.h

      Perform any changes you want to the config file and save it (close the text editor, because to perform additional changes, you need to rerun the previous command)

      On the terminal, run this command:

      make

      Wait a couple of seconds for your changes to be compiled.

      EDIT: one liner that opens the config file for edition in leafpad and then, when you close leafpad, automatically applies the changes, compiling the new herbe binary…

      cd ~/herbe && mv ~/herbe/herbe ~/herbe/herbe.off & sleep 1.5 && leafpad ~/herbe/config.h && make

      Done!

      • This topic was modified 3 years, 5 months ago by PPC.
      • This topic was modified 3 years, 5 months ago by PPC.
      • This topic was modified 3 years, 5 months ago by PPC.
      #50142
      Member
      PPC

        Since I use notifications so much, last night I ended up creating a tiny GUI “notification center”, to access the notification’s log and turn notifications on/off:

        #!/bin/bash
        #Notification center - meant to be used with herbe deamonless notification system, on antiX Linux
        #This script assumes that you installed herbe as advised in https://www.antixforum.com/forums/topic/how-to-have-system-notifications-in-antix-without-using-system-resources/
        #This means that the "herbe" binary was compiled in the folder ~/herbe (and remains there), and you are using the script "notify-send" to process notifications using herbe
        #
        #Set window icon:
        window_icon="/usr/share/icons/papirus-antix/22x22/apps/cs-notifications.png"
        #check if herbe binary exist, and change $status accordingly
        [ ! -f ~/herbe/herbe ] && status="notifications are disabled" || status="notifications are enabled"
        selection=$( yad --center --window-icon=$window_icon --title="antiX notification center" --text="\n Choose to turn system notifications on or off \n \n ($status) \n" --button="Notification's log":3 --button="OFF":2 --button="ON":1 )
        foo=$?
        		if [[ $foo -eq 1 ]]; then
        			mv ~/herbe/herbe.off ~/herbe/herbe & notify-send "System notifications are now enabled"
        		fi
        		if [[ $foo -eq 2 ]]; then
        			notify-send "System notifications will be disabled" && mv ~/herbe/herbe ~/herbe/herbe.off
        		fi   
        		if [[ $foo -eq 3 ]]; then
        			 geany ~/.config/notifications_log.txt
        		fi       
        
        #50143
        Moderator
        BobC

          I will give this a try by next weekend

          Daily driver distro https://www.antixforum.com

          #50149
          Member
          PPC

            How to have system notifications in antiX without using system resources (no Deamons running in RAM)

            Revised How-to:

            1- Pre-requeriments (this takes probably about 20 Mb of disk space):
            To ensure you can use Herbe (available in http://github.com/dudik/herbe/), run this command in the terminal [enter your password if asked to):

            sudo apt install git libx11-dev libxft-dev

            2.1- “Installing” Herbe- in the terminal run this commands (it’s way less than 1 Mb of disk space):

            
               cd
               git clone http://github.com/dudik/herbe
               cd ~/herbe
               curl http://patch-diff.githubusercontent.com/raw/dudik/herbe/pull/11.diff | git apply
               cp config.def.h config.h
               make

            This will compile a “herbe” binary file in the sub-folder “herbe”, inside your Home folder

            2.2- Creating herbe’s editable configuration file

            touch ~/herb/Xresources
            geany ~/herb/Xresources

            In thist text file, paste the default herb’s configuration (feel free to edit anything you want), and then save it:

            
            herbe.background_color: #3e3e3e
            herbe.border_color: #ececec
            herbe.font_color: #ececec
            herbe.font_pattern: monospace:size=10
            herbe.line_spacing: 5
            herbe.padding: 15
            herbe.width: 350
            herbe.border_size: 2
            herbe.pos_x: 30
            herbe.pos_y: 60
            ! 0 = TOP_LEFT, 1 = TOP_RIGHT, 2 = BOTTOM_LEFT, 3 = BOTTOM_RIGHT
            herbe.corner: 0
            herbe.duration: 6

            3- Optional step: Backup notify-send in your system, to be on the safe side:

            sudo cp /usr/bin/notify-send /usr/bin/notify-send.BAK

            4- Download this script ( and by that I mean: copy the text from this webpage to an empty text file, save it to your ~/herbe folder as “notify-send” and make sure that the file executable)
            http://raw.githubusercontent.com/dudik/herbe/24557245869662e1885f286037ecc37038a5f791/notify-send

            5- Alter this file to use your “herbe” command: by changing it’s last line and replacing

            herbe "$@" &

            with

            xrdb ~/herbe/Xresources && ~/herbe/herbe "$@" &

            5.2- Optional step: if you want to have a log file of all your system notifications (going back to the last 20 notifications), add this new lines to the “notify-send” file, after the last line:

            #####to always have a log of only the last 20 lines:
            timestamp=$(date)
            echo $timestamp - "$@" >> ~/.config/notifications_log.txt &
            tail -20 ~/.config/notifications_log.txt > /tmp/temporary_file.txt && cp /tmp/temporary_file.txt ~/.config/notifications_log.txt

            You can view/edit the notifications log doing this, from the terminal (or clicking the ~/.config/notifications_log.txt using your file manager):

            geany ~/.config/notifications_log.txt

            6- Replace the original “notify-send” file in your system with this new one:

            sudo cp ~/herbe/notify-send /usr/bin/notify-send

            You now have system notifications available.
            You can test notifications running this command:
            notify-send " Hello world "
            This will create a notification on the upper right corner of your screen. If that shows up, the process is finished. If not, something went wrong… 🙁

            7- (Optional) Editing the notification’s configuration: (notification’s font, size, position, color, etc)
            Simply edit ~/herbe/Xresources and save the changes. They will automatically be applied to the next notification.
            Ex:
            geany ~/herbe/Xresources

            _____________________________

            Why compile the herbe executable inside your Home folder, instead of installing it system wide?
            Easy: this allows you to toggle notifications on and off without needing administration privileges (sudo)

            To toggle notifications off:

            notify-send "System notifications will be disabled" && mv ~/herbe/herbe ~/herbe/herbe.off

            To toogle notifications back on:

            mv ~/herbe/herbe.off ~/herbe/herbe && notify-send "System notifications are now enabled"

            If, for some reason you want to uninstall herbe (or use any other notification application, like Dunst, etc):
            sudo cp /usr/bin/notify-send.BAK /usr/bin/notify-send
            Then you may delete herbe’s folder

            Enjoy, P.

            • This reply was modified 3 years, 5 months ago by PPC.
            #50152
            Anonymous

              > curl https://patch-diff.githubusercontent.com/raw/dudik/herbe/pull/11.diff | git apply

              By now, you realize that I chafe at the prospect of blindly, trustingly, curl | pipe -ing anything, dontcha?

              > Pre-requirements (this takes probably about 20 Mb of disk space)

              Wow, is this estimation based on installation to a 32-bit system? I can’t recall the exact figure, but on 64-bit I recall it being much higher (like, 40-60MB)… and I’ve worried that detail represents a barrier-to-entry to some folks who might be interested in delving into DIY projects.

              For tiny herbe project, and many others, we could eliminate the “install git and…” instruction and, instead, coach “visit the project repo page, click ‘Code’, click ‘Download zip‘ and…”

              To self-compile and use herbe… beyond any “prerequisites”, one really only needs its c file and a Makefile. That separate .h file (and the directive to rename it at build time) were only setup that way toward accommodating both *BSD and linux

              here’s my attempt at describing a “Revised How-to get started”:
              download the 4.5kb attachment to this post
              cd /tmp and extract the archive content
              “sudo apt install libx11-dev libxft-dev” (4MB?)
              cd /tmp/he && make herbe
              (to test): /tmp/he/herbe “hello world” and any unquoted wordstrings will display to “separate lines”

              I’m enthusiastic about seeing herbe put to use as a learning (c, c++, Xlib, Xft) tool.
              herbe “does what it does” in only 200 lines of code (and was written by a school/university -aged kiddo!)
              The 4.5kb “big” size of the attachment is due to my inclusion of a notes file, listing URLs of forks and mods, jotted after I read manyroads post mentioning herbe

              I am not enthusiastic about encouraging folks to create self-induced system vulnerabilities, by overshadowing known/predictable system-wide “commands” (notify-send) with locally-pathed analogues.

              previous herbe discussion (December 2020) here: https://www.antixforum.com/forums/topic/herbe-notifications/

              #50156
              Member
              PPC

                Thanks for your input, skidoo, that, as always, I value greatly.
                I tested on a antix 19.3 full 64 bits virtual machine and the “herbe” compiled binary did not need any dependency to run
                As you can see, it’s patched to use an editable Xresource config file (that, since I found it was not used in antiX, hijacked it for only herbe’s use. The correct instructions probably should point to creating (if not existing already) “~/.Xresources” and appending herbe’s config to it’s end

                Since I installed the dependencies needed to compile on my 64 bits system (about 5,5 and 7,5 Mb of disk space, each), but had already installed “git”, I (quite randomly) figured that the installation of Git took more or less 10Mb of disk space… I now checked, and the git-core folder is about 22Mb, so a more approximated estimation would be about double my initial estimation, about 40Mb of disk space?

                Without the (it’s called patch, in herbe’s config file, although it clearly is not) notify-send “patch” file herbe’s use is very limited, to applications that can be configured to do a certain action, instead of relying in the “default” notify-send command.

                I confess that I know absolutely nothing about the notify-send script, other than the fact that I found it listed int herbe’s github page and I edited it to use the (non system wide installed) herbe binary and also create a notification log… I trust you, if you tell me it’s a security risk… Is it? and if so, is there a way around it that you can think of? Having notifications out of the box in antiX for less than 30Kb, and no CPU/RAM usage seems too good to be true?

                also, on the original herbe’s thread, you said

                “sure, some day, when it matures.
                As is, the utility does not accept commandline options nor does it read prefs from a configfile.
                Font, size, position, duration, bg/fg colors… all parameters are hardcoded, necessitating
                “edit config.h, then recompile” in order to change any of the attributes.”

                With the Xresources’s patch, that problem no longer exists- I think that’s a good thing- it’s my very first time patching something…

                P.

                #50159
                Anonymous

                  Could you please clarify:
                  herbe can be used in place of notify-send, i.e. from cli or scripts,
                  but system proper notifications from applications (download completed, battery low, now playing …) will not work?

                  #50163
                  Anonymous

                    the potential security risk:
                    jimmy edits his $PATH, prepending ~/bin
                    jimmy uses the locally-pathed, same-named “notify-send”…

                    …any process running under the authority of jimmy’s user account has ability to inject/edit/tamper/replace the ~/bin/herbe executable. Each time “notify-send” runs, it’s a “hope and pray the executable hasn’t been unknowingly tampered” scenario. Adding “curl | yer mom” into the mix exacerbates the risk ~~ amounts to jimmy willing inviting “silent tampering” by doing so. Any tamper-prone executable is vulnerable to the whims of curl-piped scripted commands

                    ________________________________

                    a step further (aka “be aware, but… the small stuff, above, is probably moot“):

                    Per the antiX -shipped sudoers configuration, jimmy’s account is automatically a member of the sudoers group and, “for the sake of convenience” the antiX -shipped sudoers configuration does not force an immediate timeout/reauth with each invocation of sudo.

                    Result: during the “sudo timeout grace period”, the operating system is vulnerable to any (silent,scripted,curl-piped?) commands.

                    #50165
                    Anonymous

                      system proper notifications from applications (download completed, battery low, now playing …) will not work?

                      yes, will be affected.
                      Cannot definitively say “will not work”, can definitively say the calls to notify-send will be hijacked and redirected to the feature-limited herbe executable (which will be unable to process some of the parameters aka “commandstring options”) ( options like, –icon= for example)

                    Viewing 9 posts - 1 through 9 (of 9 total)
                    • You must be logged in to reply to this topic.