How do I build a launcher script for Urxvt? (solved)

Issues and / or general discussion relating to Puppy

Moderator: Forum moderators

Post Reply
User avatar
peppyy
Posts: 330
Joined: Fri Jan 22, 2021 2:11 pm
Location: VT USA
Has thanked: 66 times
Been thanked: 28 times

How do I build a launcher script for Urxvt? (solved)

Post 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
desktop(11).jpg (115.21 KiB) Viewed 1013 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.

Last edited by peppyy on Sun Feb 26, 2023 1:41 pm, edited 1 time in total.

Puppy Linux. It just works!
Foassapup 9.5 64-(Frugal) Mobo, M5A99FX PRO - CPU, AMD FX-6300 6 core - mem,32GB - Storage
ssd 128GB M4 - ssd-256GB APS - ssd-1TB PNY - GPU GeForce GTX 1060 GAMING X 6G. Yes it's a Mutt.

geo_c
Posts: 2879
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2200 times
Been thanked: 876 times

Re: How do I build a launcher script for Urxvt?

Post 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.

geo_c
Old School Hipster, and Such

User avatar
Trapster
Posts: 180
Joined: Sat Aug 01, 2020 7:44 pm
Has thanked: 1 time
Been thanked: 50 times

Re: How do I build a launcher script for Urxvt?

Post 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"
User avatar
peppyy
Posts: 330
Joined: Fri Jan 22, 2021 2:11 pm
Location: VT USA
Has thanked: 66 times
Been thanked: 28 times

Re: How do I build a launcher script for Urxvt?

Post 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.

Puppy Linux. It just works!
Foassapup 9.5 64-(Frugal) Mobo, M5A99FX PRO - CPU, AMD FX-6300 6 core - mem,32GB - Storage
ssd 128GB M4 - ssd-256GB APS - ssd-1TB PNY - GPU GeForce GTX 1060 GAMING X 6G. Yes it's a Mutt.

User avatar
peppyy
Posts: 330
Joined: Fri Jan 22, 2021 2:11 pm
Location: VT USA
Has thanked: 66 times
Been thanked: 28 times

Re: How do I build a launcher script for Urxvt?

Post 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 ;)

Puppy Linux. It just works!
Foassapup 9.5 64-(Frugal) Mobo, M5A99FX PRO - CPU, AMD FX-6300 6 core - mem,32GB - Storage
ssd 128GB M4 - ssd-256GB APS - ssd-1TB PNY - GPU GeForce GTX 1060 GAMING X 6G. Yes it's a Mutt.

williwaw
Posts: 1939
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 170 times
Been thanked: 368 times

Re: How do I build a launcher script for Urxvt?

Post by williwaw »

the order of the options matter
try
urxvt -hold -e

User avatar
peppyy
Posts: 330
Joined: Fri Jan 22, 2021 2:11 pm
Location: VT USA
Has thanked: 66 times
Been thanked: 28 times

Re: How do I build a launcher script for Urxvt?

Post 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?

Puppy Linux. It just works!
Foassapup 9.5 64-(Frugal) Mobo, M5A99FX PRO - CPU, AMD FX-6300 6 core - mem,32GB - Storage
ssd 128GB M4 - ssd-256GB APS - ssd-1TB PNY - GPU GeForce GTX 1060 GAMING X 6G. Yes it's a Mutt.

User avatar
norgo
Posts: 283
Joined: Mon Jul 13, 2020 6:39 pm
Location: Germany
Has thanked: 6 times
Been thanked: 111 times
Contact:

Re: How do I build a launcher script for Urxvt?

Post by norgo »

@peppyy
urxvt -hold -e "curl wttr\.in"

williwaw
Posts: 1939
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 170 times
Been thanked: 368 times

Re: How do I build a launcher script for Urxvt?

Post 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

User avatar
norgo
Posts: 283
Joined: Mon Jul 13, 2020 6:39 pm
Location: Germany
Has thanked: 6 times
Been thanked: 111 times
Contact:

Re: How do I build a launcher script for Urxvt?

Post by norgo »

Code: Select all

#!/bin/sh
xterm -hold -e "curl wttr.in/muc"
hold-e.jpg
hold-e.jpg (43.15 KiB) Viewed 900 times
Burunduk
Posts: 251
Joined: Thu Jun 16, 2022 6:16 pm
Has thanked: 7 times
Been thanked: 127 times

Re: How do I build a launcher script for Urxvt?

Post 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"
User avatar
mikewalsh
Moderator
Posts: 6156
Joined: Tue Dec 03, 2019 1:40 pm
Location: King's Lynn, UK
Has thanked: 793 times
Been thanked: 1979 times

Re: How do I build a launcher script for Urxvt?

Post 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. ;)

User avatar
rockedge
Site Admin
Posts: 6539
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2748 times
Been thanked: 2620 times
Contact:

Re: How do I build a launcher script for Urxvt?

Post by rockedge »

This command:

Code: Select all

 curl wttr.in/:bash.function 

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 :thumbup2:

User avatar
peppyy
Posts: 330
Joined: Fri Jan 22, 2021 2:11 pm
Location: VT USA
Has thanked: 66 times
Been thanked: 28 times

Re: How do I build a launcher script for Urxvt?

Post 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,

Code: Select all

#!/bin/sh

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.

Puppy Linux. It just works!
Foassapup 9.5 64-(Frugal) Mobo, M5A99FX PRO - CPU, AMD FX-6300 6 core - mem,32GB - Storage
ssd 128GB M4 - ssd-256GB APS - ssd-1TB PNY - GPU GeForce GTX 1060 GAMING X 6G. Yes it's a Mutt.

williwaw
Posts: 1939
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 170 times
Been thanked: 368 times

Re: How do I build a launcher script for Urxvt?

Post 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
User avatar
rockedge
Site Admin
Posts: 6539
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2748 times
Been thanked: 2620 times
Contact:

Re: How do I build a launcher script for Urxvt?

Post 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.

Code: Select all

curl wttr.in/:help
User avatar
mikewalsh
Moderator
Posts: 6156
Joined: Tue Dec 03, 2019 1:40 pm
Location: King's Lynn, UK
Has thanked: 793 times
Been thanked: 1979 times

Re: How do I build a launcher script for Urxvt?

Post 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. ;)

User avatar
peppyy
Posts: 330
Joined: Fri Jan 22, 2021 2:11 pm
Location: VT USA
Has thanked: 66 times
Been thanked: 28 times

Re: How do I build a launcher script for Urxvt?

Post 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 :ugeek:

Puppy Linux. It just works!
Foassapup 9.5 64-(Frugal) Mobo, M5A99FX PRO - CPU, AMD FX-6300 6 core - mem,32GB - Storage
ssd 128GB M4 - ssd-256GB APS - ssd-1TB PNY - GPU GeForce GTX 1060 GAMING X 6G. Yes it's a Mutt.

User avatar
peppyy
Posts: 330
Joined: Fri Jan 22, 2021 2:11 pm
Location: VT USA
Has thanked: 66 times
Been thanked: 28 times

Re: How do I build a launcher script for Urxvt?

Post 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. :o Guess I should read the alt text tool-tips.

Puppy Linux. It just works!
Foassapup 9.5 64-(Frugal) Mobo, M5A99FX PRO - CPU, AMD FX-6300 6 core - mem,32GB - Storage
ssd 128GB M4 - ssd-256GB APS - ssd-1TB PNY - GPU GeForce GTX 1060 GAMING X 6G. Yes it's a Mutt.

step
Posts: 546
Joined: Thu Aug 13, 2020 9:55 am
Has thanked: 57 times
Been thanked: 198 times
Contact:

Re: How do I build a launcher script for Urxvt?

Post 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.

User avatar
peppyy
Posts: 330
Joined: Fri Jan 22, 2021 2:11 pm
Location: VT USA
Has thanked: 66 times
Been thanked: 28 times

Re: How do I build a launcher script for Urxvt?

Post 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!

Puppy Linux. It just works!
Foassapup 9.5 64-(Frugal) Mobo, M5A99FX PRO - CPU, AMD FX-6300 6 core - mem,32GB - Storage
ssd 128GB M4 - ssd-256GB APS - ssd-1TB PNY - GPU GeForce GTX 1060 GAMING X 6G. Yes it's a Mutt.

Burunduk
Posts: 251
Joined: Thu Jun 16, 2022 6:16 pm
Has thanked: 7 times
Been thanked: 127 times

Re: How do I build a launcher script for Urxvt?

Post 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.

User avatar
peppyy
Posts: 330
Joined: Fri Jan 22, 2021 2:11 pm
Location: VT USA
Has thanked: 66 times
Been thanked: 28 times

Re: How do I build a launcher script for Urxvt? (solved)

Post 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."

Puppy Linux. It just works!
Foassapup 9.5 64-(Frugal) Mobo, M5A99FX PRO - CPU, AMD FX-6300 6 core - mem,32GB - Storage
ssd 128GB M4 - ssd-256GB APS - ssd-1TB PNY - GPU GeForce GTX 1060 GAMING X 6G. Yes it's a Mutt.

User avatar
rockedge
Site Admin
Posts: 6539
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2748 times
Been thanked: 2620 times
Contact:

Re: How do I build a launcher script for Urxvt? (solved)

Post by rockedge »

I am getting the same message........ :o

User avatar
mikewalsh
Moderator
Posts: 6156
Joined: Tue Dec 03, 2019 1:40 pm
Location: King's Lynn, UK
Has thanked: 793 times
Been thanked: 1979 times

Re: How do I build a launcher script for Urxvt? (solved)

Post 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. ;)

Post Reply

Return to “Users”