On 8/28/22 15:58, ToddAndMargo via perl6-users wrote:
Hi All,

I am thinking of using

    BEGIN {}

to fire up a splash screen (libnotify).

Question: is what happens between the brackets
isolated from the rest of the code?   If I set
variable values or declare variables, are they
wiped out, etc.?

Many thanks,
-T

Follow up:

Thank you all for the help!

My splash screen pops up whilst the
rest of the program compiles.

Here is my BEGIN code.   If you are
wondering why all the variables when
I could just write it in the run line,
it is becasue the names of the variables
and the comments next to them tell me what
the parameters of notify-send are and
how to use them.  Much easier to maintain.



#!/usr/bin/env perl6

use RunNoShellLib :RunNoShell, :RunNoShellCode, :RunNoShellErr;

BEGIN {
   # Splash Screen

 ( my $ProgramName   = $?FILE ) ~~ s|.*"/"||;
   my Str $NotifyStr = "\nStarting $ProgramName\n";
   my Str $Icon      = "/home/linuxutil/Images/Info.png";
   my Str $Title     = "$ProgramName Splash Screen";
   my Str $Timeout   = "8000";  # milliseconds

RunNoShell( "notify-send -u normal -t \"$Timeout\" -i \"$Icon\" \"$Title\" \"$NotifyStr\"" );
}



:-)

Love Raku!

-T

Reply via email to