screenFetch icon indicating copy to clipboard operation
screenFetch copied to clipboard

Fast mode?

Open danwdart opened this issue 4 years ago • 1 comments

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!

danwdart avatar Jan 31 '22 11:01 danwdart

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.

OPhamster avatar Mar 10 '24 09:03 OPhamster