HorlogeSkynet / archey4

:computer: Maintained fork of the original Archey (Linux) system tool
https://git.io/archey4
GNU General Public License v3.0
295 stars 37 forks source link

[FEATURE] Implements a `-s` option to make Archey take a screenshot #75

Closed HorlogeSkynet closed 4 years ago

HorlogeSkynet commented 4 years ago

Title should be self-explanatory :smile:

Description

New CLI option/argument. Implemented logic wants to be EAFP, handling many different cases in a "best-effort" fashion. One may want to add its specific (omitted ?) program to the supported list (really easy).

:warning: Important note : Sometimes it's not possible to directly specify the output filename. In such cases, the targeted directory should be honored.

:warning: Important note (2) : This feature will be considered as a "soft-extension" of Archey, so no screenshot program has been (and will be) added to required/optional dependencies lists.

:warning: Important note (3) : It's a first very basic implementation, it might evolve in the future.

Thanks :bow:

Reason and / or context

Well, ScreenFetch supports it, and even some other Archey forks. So I guess such a feature was definitely missing here (?).

How has this been tested ?

Locally, with flameshot, scrot, import (ImageMagick) & gnome-screenshot.

Types of changes :

Checklist :

HorlogeSkynet commented 4 years ago

That's very clean :+1:

ingrinder commented 4 years ago

I noticed on my system (with ImageMagick), sometimes the screenshot was being taken before the output from Archey had appeared, so I've added a fixed delay with a countdown before it's taken. Unfortunately I've tried solutions like forcing the stdout buffer to flush but there's no easy way to check when the terminal has actually rendered it, so this was the only thing I could come up with :confused:

HorlogeSkynet commented 4 years ago

Other implementations also play with delay features offered by some programs (all of them ?), so I guess that makes sense. ~~I'm not convinced about the special print call flushing output though. I guess we may workaround the issue without it ¯_ (ツ) _/¯ EDIT : Maybe we could rather add flush=True to Output.output print call(s) instead ?~~

HorlogeSkynet commented 4 years ago

Woops, sorry about my previous message : I didn't get your commit well. I'm all good with latest changes, this piece of code will evolve for sure in the near future anyway. We definitely need more feed-backs from end-users :ok_hand:

I took the liberty to remove one of your print-ed message ; I think we can keep Archey quiet if the passed command got executed well :man_shrugging:

ingrinder commented 4 years ago

Ah yes, sorry, that sneaked in my last commit while I was figuring out what was taking the screenshot on my system -- For some reason in VS Code under XWayland, some of the environment variables are set wrong (I think it was XDG_CURRENT_DESKTOP) and the screenshot from gnome-screenshot is black... But I think this is a VS Code issue rather than anything to do with us!

As you say, I'm sure we'll be refining this implementation in future regardless :smiley:

HorlogeSkynet commented 4 years ago

Well that's indeed weird, good luck with the investigation :open_mouth: