Page 1 of 1
How do I build a launcher script for Urxvt? (solved)
Posted: Sat Feb 25, 2023 1:33 pm
by peppyy
I discovered that I can get my local weather in terminal by using
curl wttr\.in
I love the simplicity and have been trying to create a script to do it with one click.
- desktop(11).jpg (115.21 KiB) Viewed 1017 times
I am running into a couple issues though.
One is that the -hold command doesn't seem to do anything. How do I keep the window from closing?
Is there something like pause that I could use?
I am pretty sure I can work out the geometry after reading the man pages.
I have tried several combinations like
urxvt -e -hold curl wttr\.in
and it just flashes on the screen so I can't see if it is actually working.
Solved page 3.
Thanks everyone.
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 1:42 pm
by geo_c
That is pretty cool. I just used the command and what weather is giving? Does it approximate your location from the ip orign?
I'm sorry I don't have the answer to the question of keeping the window open with a script.
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 2:08 pm
by Trapster
I'm not sure why your terminal wont "hold" but you can also have it make a .png image.
What pup version are you using?
I've been using this script for years to create an image, then I have it uploaded to my website.
Harrison.png = Name of file.
04268 = Zip code.
Code: Select all
curl -o Harrison.png "wttr.in/04268.png?u"
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 2:15 pm
by peppyy
It pulls your location from your ip address somehow. There is a great readme at https://github.com/chubin/wttr.in that tells you how to set a location etc. You can even change windspeed etc. There are different versions too like
curl v2.wttr\.in which sort of graphs the temperature.
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 2:25 pm
by peppyy
@Trapster I am using fossapup64 9.5
Guess I am not as quick as i once was. I make notes to remember where my notes are now
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 6:19 pm
by williwaw
the order of the options matter
try
urxvt -hold -e
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 7:09 pm
by peppyy
@williwaw
I tried
urxvt -hold -e curl wttr\.in
I made it executable and named it weather.sh
Still just pops up for a second and closes.
I think I must be missing something in between?
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 8:02 pm
by norgo
@peppyy
urxvt -hold -e "curl wttr\.in"
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 8:14 pm
by williwaw
I tried the command urxvt -hold -e curl v2.wttr\.in/01645
in a terminal and it works, but when I added it to a script that I have in my /root/startup folder it does not work. I think I have to fiddle with my startup script some, as another process needs to finish, but this is a bit of a digression.
another thing to be noted is in my easyos, rxvt is a smylink to urxvt, and xterm is a script that calls rxvt, where,
Xterm
Code: Select all
#!/bin/sh
#rxvt does not understand the '-hold' option.
if [ "`echo -n ${*} | grep '\-hold '`" != "" ];then
EXECCOMMAND="`echo -n ${*} | grep -o ' \-e .*' | sed -e 's/ \-e //'`"
if [ "$EXECCOMMAND" != "" ];then
echo '#!/bin/sh' > /tmp/xterm_simulate_hold.sh
echo "$EXECCOMMAND" >> /tmp/xterm_simulate_hold.sh
echo 'echo' >> /tmp/xterm_simulate_hold.sh
echo 'echo -n "FINISHED. PRESS ENTER KEY TO CLOSE THIS WINDOW: "' >> /tmp/xterm_simulate_hold.sh
echo 'read simuldone' >> /tmp/xterm_simulate_hold.sh
chmod +x /tmp/xterm_simulate_hold.sh
exec rxvt -e /tmp/xterm_simulate_hold.sh
fi
fi
exec rxvt "${@}"
so you may have to dig deeper to see just what terminal is called in your distribution before "-hold" works
the option "-h" as I recall, works in different terminal apps, but I cannot recall which ones
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 8:29 pm
by norgo
Code: Select all
#!/bin/sh
xterm -hold -e "curl wttr.in/muc"
- hold-e.jpg (43.15 KiB) Viewed 904 times
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 9:17 pm
by Burunduk
Fossapup64-9.5
with -hold, lalt-F4 to close:
Code: Select all
#!/bin/sh
urxvt -title "wttr.in weather" -geometry 130x40 -hold -e bash -c "curl wttr\.in"
without -hold, enter to close:
Code: Select all
#!/bin/sh
urxvt -title "wttr.in weather" -geometry 130x40 -e bash -c "curl wttr\.in; read"
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 9:27 pm
by mikewalsh
@peppyy :-
This works in a script for me:-
Code: Select all
#!/bin/sh
#
# Run 'weather' in terminal...
#
rxvt -title ' ~ Local weather ~' -bg '#ffff80' -fg black -geometry '130x40' rxvt -hold -ls -e curl wttr.in/~Kings+Lynn
You can of course set foreground[-fg]/background[-bg] colours to whatever you want. Ditto the geometry.
It works better calling rxvt than calling urxvt - don't ask me why. And adding that '-ls' between '-hold' & '-e' makes all the difference. We did some trial and error stuff for calling terminals that then auto-ran various things, when I was building the DriveSpeed! speed tester utility, and again with the manual TRIM utility I put together a couple of months later.
I believe it was bigpup who found the '-ls' option. After that, everything just worked....
As williwaw says, in most Puppies rxvt is usually a sym-link to urxvt, but for some reason urxvt itself doesn't seem to like being called from a script.
Mike.
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 9:59 pm
by rockedge
This command:
produced:
Code: Select all
#! /usr/bin/env bash
# If you source this file, it will set WTTR_PARAMS as well as show weather.
# WTTR_PARAMS is space-separated URL parameters, many of which are single characters that can be
# lumped together. For example, "F q m" behaves the same as "Fqm".
if [[ -z "$WTTR_PARAMS" ]]; then
# Form localized URL parameters for curl
if [[ -t 1 ]] && [[ "$(tput cols)" -lt 125 ]]; then
WTTR_PARAMS+='n'
fi 2> /dev/null
for _token in $( locale LC_MEASUREMENT ); do
case $_token in
1) WTTR_PARAMS+='m' ;;
2) WTTR_PARAMS+='u' ;;
esac
done 2> /dev/null
unset _token
export WTTR_PARAMS
fi
wttr() {
local location="${1// /+}"
command shift
local args=""
for p in $WTTR_PARAMS "$@"; do
args+=" --data-urlencode $p "
done
curl -fGsS -H "Accept-Language: ${LANG%_*}" $args --compressed "wttr.in/${location}"
}
wttr "$@"
Works pretty good. But @norgo's little version with 2 lines seems to do the same
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 10:08 pm
by peppyy
@norgo I knew I was missing something. It works for me also. I tried the "quotes" too and it did not hold.
I just wrote a text document and named it .sh instead of .txt, Made it executable by right click, permissions and chose (Make executable/searchable). I am guessing the main reason was not including the whole command in the "quotes"
I am not sure what the /muc is on the end but it works without it.
Code: Select all
#!/bin/sh
xterm -hold -e "curl wttr.in"
Then other mistake I was making was apparently using urxvt instead of xterm. The,
is now so far from my mind I can't remember it.
20 years ago, when Puppy and I were younger, I knew all this stuff It got so easy in the past several years that it was all done with a right-click menu, so I have forgotten most of it.
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 10:26 pm
by williwaw
Then other mistake I was making was apparently using urxvt instead of xterm.
but for some reason urxvt itself doesn't seem to like being called from a script.
hmm. I have urxvt working fine in a script as follows, but I need to close the urxvt window (which is being held open with the -h) before I can open a second urxvt window for the weather.
perhaps a more elegant soultion would be to cat /etc/hosts, then run the weather sequentially in the same window.
a different possibility would be to verify that
wget -O /etc/hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
has updated etc/hosts without using cat
Code: Select all
#!/bin/sh
cp /mnt/sda2/portable/.bashrc /root/.bashrc
source /root/.bashrc
cp /mnt/sda2/portable/.Xdefaults /root/.Xdefaults
cp /mnt/sda2/portable/sakura.conf /root/.config/sakura.conf
cp /mnt/sda2/portable/jwmrc-personal /root/.jwm
cp /etc/hosts /etc/hosts.default
wget -O /etc/hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
urxvt -hold -e cat -n /etc/hosts
urxvt -hold -e curl v2.wttr\.in
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 10:43 pm
by rockedge
peppyy wrote:/muc is on the end but it works without it.
The /muc
is the Airport code for the Munich airport weather. Any airport code will work like /jfk
or /dia
generating the help will list the other possible location and language coding options.
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 11:00 pm
by mikewalsh
All of the above just goes to show what it always does......that there's multiple different ways of achieving the same outcome. Much will depend on whether you're an "ubergreek" - for whom stuff must not ONLY 'look right', but it must also be technically correct - or just an ordinary "geek" (like me!) for whom function is more important than 'form'.
In other words, I couldn't care less what profanities/complaints the terminal may be spitting out in the background, so long as I get the desired result.....and nothing crashes.
(*shrug*)
Mike.
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 11:03 pm
by peppyy
@rockedge I am fortunate, (Or perhaps not so fortunate) to have an isp in our town who has a fiber hub about 2 miles away, that always lets you know where the address is. In my browser I always have it ask.
Now I will work on the other fun stuff I can do with it Geometry and fonts sound like they could be a lot of fun in customizing the interface. Do you know if the terminal commands work when you use "xterm" the same as when you use "urxvt" ?
See, I am overthinking things again
Re: How do I build a launcher script for Urxvt?
Posted: Sat Feb 25, 2023 11:14 pm
by peppyy
mikewalsh wrote: ↑Sat Feb 25, 2023 11:00 pm
All of the above just goes to show what it always does......that there's multiple different ways of achieving the same outcome. Much will depend on whether you're an "ubergreek" - for whom stuff must not ONLY 'look right', but it must also be technically correct - or just an ordinary "geek" (like me!) for whom function is more important than 'form'.
In other words, I couldn't care less what profanities/complaints the terminal may be spitting out in the background, so long as I get the desired result.....and nothing crashes.
(*shrug*)
Mike.
I can agree. All I want is to be able to do something as simply as possible.
At my age though, I would rather get it done sooner than later... I might forget tomorrow.
BTW, I just used the ugeek icon replying to Rockedge. I thought the glasses and the beard meant elder-geek. Guess I should read the alt text tool-tips.
Re: How do I build a launcher script for Urxvt?
Posted: Sun Feb 26, 2023 10:38 am
by step
This works for me
Code: Select all
urxvt -geometry 80x80 -e sh -c 'curl v2.wttr.in; read'
Close the window or press Enter to end - the sh
that runs inside urxvt
is waiting to read
keyboard input, which holds urxvt from closing.
I added geometry (80 rows by 80 columns) to make room for the plots that wttr.in sends for my location.
-hold
isn't needed anymore but it won't hurt.
Re: How do I build a launcher script for Urxvt?
Posted: Sun Feb 26, 2023 1:35 pm
by peppyy
@step
That is nice with the v2 however it doesn't display correctly with my current font. I like the 3 day so here is what I came up with.
Code: Select all
urxvt -geometry 127x42 -e sh -c 'curl wttr.in; read'
Now I can have a tiny file I can give to my wife, so she can check the weather this way too. Off to find the perfect icon, or create one
Thanks everyone for the help!
Re: How do I build a launcher script for Urxvt?
Posted: Mon Feb 27, 2023 6:18 am
by Burunduk
rockedge wrote: ↑Sat Feb 25, 2023 10:43 pm
The /muc
is the Airport code for the Munich airport weather. Any airport code will work like /jfk
or /dia
At the moment it doesn't work. Use EDDM instead of MUC.
Re: How do I build a launcher script for Urxvt? (solved)
Posted: Fri May 05, 2023 9:05 pm
by peppyy
Looks like this is getting phased out. Current reply is
"Sorry, we are running out of queries to the weather service at the moment.
Here is the weather report for the default city (just to show you what it looks like).
We will get new queries as soon as possible."
Re: How do I build a launcher script for Urxvt? (solved)
Posted: Fri May 05, 2023 10:58 pm
by rockedge
I am getting the same message........
Re: How do I build a launcher script for Urxvt? (solved)
Posted: Sat May 06, 2023 2:13 am
by mikewalsh
I was getting this a couple of days ago, but as of earlier this evening it's back up and running again, so....
It's anybody's guess (I guess!)
Mike.