It’s a string of commands. Not separated properly.
Test each one individually?!
→ first command is: date
→ second command is: cat /sys/class/power_supply/ip5xxx-battery/capacity
→ third command here is: $(sudo tuptime | awk -F'=' '/System uptime:/ {print substr($2, 1, length($2)-3)}')" "
but it is syntactically incorrect, it seems, for what you want the output to be.
tuptime | awk -F'=' '/System uptime:/ {print substr($2, 1, length($2)-3)}'
produces just the uptime, like this: 1d 9h 1m
Make sure you have the command “tuptime” available - install it if you don’t have it.
It doesn’t need sudo to run.
And correct the awk command to provide the desired output format.
→ last command is: curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=20902 \ | sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3 \1/p'
and it works, giving output like this:
64°F Partly Cloudy
→ a string of commands
separate them from each other by &&
or put them in a script with some extra logic to make sure that a later command is still executed even if the one before fails
@ Nachlese – I very much appreciate your work/time on this. I’ve run your cleaner, reworked commands and they produce your results in my terminal.
The rub: the syntax so far, doesn’t work with gxmessage Using gxmessage as the command to set up the rest simply results in a print-out of the commands, not their calculation. Much the way my original cat /sys/class/power_supply/ip5xxx-battery/capacity printed but didn’t execute.
If I remove cat /sys/class/power_supply/ip5xxx-battery/capacity from the original script, the other commands work without complaint.
As an aside, I’m using Manjaro Phosh Beta ver 33 on a PinePhone Beta, and for some reason, notify-send doesn’t work with said setup.
You folks are getting places–@dmt’s s= start executes all commands in gxmessage.
The message also prints out s= Can I remove that, and also for the battery output, since it’s just a plain number, how can I print a following % or a preceding Batt:?
(It’s such a pleasure to huddle with people who know so much more than I do)
tuptime, by itself, delivers this output (on my machine, an intel laptop)
tuptime
System startups: 1 since 23:22:06 09.06.2023
System shutdowns: 0 ok + 0 bad
System life: 1d 17h 26m 12s
System uptime: 100.0% = 1d 17h 26m 12s
System downtime: 0.0% = 0s
Average uptime: 1d 17h 26m 12s
Average downtime: 0s
Current uptime: 1d 17h 26m 12s since 23:22:06 09.06.2023
The following awk command will need to be tailored to extract the information from it that you want.
I found that print-out excessive as well, and I just kept playing with print cuts until I got something briefer. The great thing about tuptime is that it remembers your last uptime–so if your machine was up for 59 mins, when you restart it, uptime begins at 59 mins. You can reset everything by blowing away tuptime’s cache in /var
Thanks to folks’ very helpful posts/advice, the script is working now. I made an addition to deal with the PinePhone’s weird two-battery output (one for the phone’s battery, the other for the keyboard’s battery)–the script prints out both percentages and then combines them. The script::
It’s a little crowded all on one line. I would like to put each print-out onto a separate line with a space in between each line. I have looked hard but cannot find a way to do this in gxmessage.
Your first approach did it; the second approach had no effect on the print-out; I wonder why.
I looked high and low for a carriage return solution, so your commands were familiar, I just never found examples of how to put them together.
Odd that it was so easy to find/use something like batt3="= $(($batt1 + $batt2))%" which is much more complicated than simple spacing.
Re: conky–I’ve always been a fan and probably could get it going on Phosh. But the trouble with Phosh is that its home screen is a mess, so I rarely go there and just keystroke whatever I can. I remember in earlier Lubuntu running a permanent conky across the panel and window titlebar with uptime, etc. The setup was like Window’s Serious Samurai, if that rings a bell, though I’m not certain Phosh would allow such placement.
As for marking this solved, I’m going to mark your last post as the solution, even though you solved the script issues in two posts. Unless you suggest differently.
That’s dealt with by the shell before being passed to gxmessage.
The newline is a special char (which represents a line feed aka LF) and should be dealt with by gxmessage, except that the dev has chosen not to implement that functionality.
It does however work with literal line feeds (LF), which is what you get with either of those methods, and also copy/pasting the literal LF char (unicode) but that gives the same result as pressing enter/return.