KittyKatt / screenFetch

Fetches system/theme information in terminal for Linux desktop screenshots.
GNU General Public License v3.0
3.82k stars 453 forks source link

Fast mode? #742

Open danwdart opened 2 years ago

danwdart commented 2 years ago

I'm submitting a ... (check one with "x")

[ ] bug report
[ ] new distro request
[x] request

Can we have a fast mode so I can add it to .bashrc? Is there some kind of caching system or just a mode to say "get only the things that won't take ages to get"? Thanks!

OPhamster commented 4 months ago

Ah I may be dodging your question here, but since I don't expect my information to change that often - I use a simple script to cache it on my end.

$ cat cached_screenfetch 
#!/bin/bash

# you could even keep this in a place that isn't scrubbed on reboots
SCREENFETCH_CACHE=/tmp/screenfetch.info
CAT_BIN=/usr/bin/cat

function read_from_cache { $CAT_BIN $SCREENFETCH_CACHE; }
# we don't want to see any errors and we want to wrap long lines
# short and sweet
function write_to_cache { screenfetch -E -w > $SCREENFETCH_CACHE; }

if [[ -f $SCREENFETCH_CACHE ]]
then
    read_from_cache
else
    write_to_cache
    read_from_cache
fi
# the first fresh screenfetch
$ time ./cached_screenfetch
# hiding the output
real    2m0.773s
user    0m0.692s
sys     0m0.448s

# successive calls
$ time ./cached_screenfetch 
 # hiding the output
real    0m0.009s
user    0m0.000s
sys     0m0.009s

Hopefully this helps.