PADD icon indicating copy to clipboard operation
PADD copied to clipboard

Provide option to mimic discontinued chronometer and exit PADD when run

Open daPhipz opened this issue 10 months ago • 12 comments

I used the old chronometer as part of my MOTD when SSHing into the Pi running Pi-Hole. This gave me a quick overview about the current status and load on the Pi.

I have never heard of PADD before, and now with Pi-Hole 6 out, the old chronometer is discontinued. When installing and running PADD (v4), it seems to be running in a loop and always updating the displayed info regularly. Pressing Ctrl-C gives me my prompt back.

Is there a way to have PADD run only once, exit the program and show me my prompt again? That way, I can use it as a one-time quick look whenever I SSH into the Pi running Pi-Hole and then use my Pi in another way - as I was doing before.

daPhipz avatar Feb 24 '25 18:02 daPhipz

Huh - I didn't realise that was even possible with chronometer. If you're looking to display information in the MOTD, you could even use the API to grab the relevant info, without fully running PADD

PromoFaux avatar Feb 24 '25 18:02 PromoFaux

Currently there is no 'run-once-and-exit' option which prints everything nicely. You could use the -j option for some basic stats

./padd.sh -j
Establishing connection with FTL...
No authentication required.
{"domains_being_blocked":1003065,"dns_queries_today":32935,"ads_blocked_today":3998,"ads_percentage_today":12.1,"clients": 10}

yubiuser avatar Feb 24 '25 20:02 yubiuser

I hacked this together really quickly for similar reasons:

diff --git a/padd.sh b/padd.sh
index 8fa5ef8..b7f1307 100755
--- a/padd.sh
+++ b/padd.sh
@@ -17,6 +17,8 @@ export LC_NUMERIC=C
 # VERSION
 padd_version="v4.0.0"

+runOnce=0
+
 # LastChecks
 LastCheckPADDInformation=$(date +%s)
 LastCheckFullInformation=$(date +%s)
@@ -1692,6 +1694,10 @@ NormalPADD() {
     # Output everything to the screen
     PrintDashboard ${padd_size}

+    if [ "${runOnce}" -eq 1 ]; then
+       break
+    fi
+
     # Sleep for 5 seconds
     # sending sleep in the background and wait for it
     # this way the TerminalResize trap can kill the sleep
@@ -1802,6 +1808,7 @@ DisplayHelp() {
 :::  --server <DOMAIN|IP>    domain or IP of your Pi-hole (default: localhost)
 :::  --secret <password>     your Pi-hole's password, required to access the API
 :::  --2fa <2fa>             your Pi-hole's 2FA code, if 2FA is enabled
+;;;  --runonce               display output once and exit
 :::  -j, --json              output stats as JSON formatted string and exit
 :::  -u, --update            update to the latest version
 :::  -v, --version           show PADD version info
@@ -1898,6 +1905,7 @@ while [ "$#" -gt 0 ]; do
     "-u" | "--update"   ) Update;;
     "-h" | "--help"     ) DisplayHelp; exit 0;;
     "-v" | "--version"  ) xOffset=0; ShowVersion; exit 0;;
+    "--runonce"         ) runOnce=1;;
     "--xoff"            ) xOffset="$2"; xOffOrig="$2"; shift;;
     "--yoff"            ) yOffset="$2"; yOffOrig="$2"; shift;;
     "--server"          ) SERVER="$2"; shift;;

k-rister avatar Feb 27 '25 15:02 k-rister

Would you like to file a pull request?

yubiuser avatar Feb 27 '25 15:02 yubiuser

Sure. When I have some more time I was going to make sure I followed the coding style, etc. and then do so.

k-rister avatar Feb 27 '25 15:02 k-rister

@daPhipz, the timeout command is a good solution for you. I use this in my .bashrc file.

PADD takes around 10 seconds to startup. timeout 12 ./padd.sh

robcmo avatar Mar 01 '25 16:03 robcmo

timeout 12 ./padd.sh

Thanks @robcmo, this is a good workaround!

daPhipz avatar Mar 05 '25 21:03 daPhipz

This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.

github-actions[bot] avatar Apr 05 '25 08:04 github-actions[bot]

As I understand it, this issue will get a fix with #443, which will land in version 4.1.0 as per #438 - correct?

daPhipz avatar Apr 05 '25 08:04 daPhipz

Correct.

yubiuser avatar Apr 05 '25 08:04 yubiuser

This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.

github-actions[bot] avatar May 06 '25 08:05 github-actions[bot]

Still open, waiting for the new release PR to be merged.

daPhipz avatar May 06 '25 08:05 daPhipz

This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.

github-actions[bot] avatar Jun 06 '25 08:06 github-actions[bot]

I'll try to give PADD some attention in the next days including a new release which will fix this issue.

yubiuser avatar Jun 16 '25 14:06 yubiuser