Skip to content

Instantly share code, notes, and snippets.

@nothub
Last active February 20, 2023 13:40
Show Gist options
  • Save nothub/91ff81bd945eb8f1e6af08492a13ff75 to your computer and use it in GitHub Desktop.
Save nothub/91ff81bd945eb8f1e6af08492a13ff75 to your computer and use it in GitHub Desktop.
updated asciiquarium
This project has moved to: https://github.com/nothub/asciiquarium
@phanirithvij
Copy link

How to make it so any keypress (other than r, p) will quit it?
Edit: Found a way. Added elsif ($in ne '-1') {quit();}, is that correct? Works for me.

patch (also including a commandline option)
--- asciiquarium.pl	2023-02-19 20:38:49.837074714 +0530
+++ /usr/bin/asciiquarium	2023-02-19 20:51:34.291968027 +0530
@@ -116,13 +116,15 @@
 
 my $classic = 0;
 my $transparent = 0;
+my $screensaver = 0;
 my $print_version = 0;
 
 GetOptions(
     'classic'     => \$classic,
     'transparent' => \$transparent,
+    'screensaver' => \$screensaver,
     'version'     => \$print_version,
-) or die "Try: $0 --classic --transparent\n";
+) or die "Try: $0 --classic --transparent --screensaver\n";
 
 if ($print_version) {
     VERSION_MESSAGE();
@@ -201,6 +203,7 @@
             if    ($in eq 'q') {quit();}  # Exit
             elsif ($in eq 'r' || $in eq KEY_RESIZE()) {last;}  # Redraw (will recreate all objects)
             elsif ($in eq 'p') {$paused = !$paused;}
+            elsif ($screensaver && $in ne '-1') {quit();} # Exit for any key (screensaver mode)
 
             $anim->animate() unless ($paused);
         }

@nothub
Copy link
Author

nothub commented Feb 19, 2023

Oh cool, thanks a lot @phanirithvij! I gonna add your patch to the application.

@nothub
Copy link
Author

nothub commented Feb 19, 2023

I have moved the file to its own git repo so contributions can be added in a cleaner way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment