Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
neofetch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
neofetch
Commits
d25de711
Commit
d25de711
authored
Dec 02, 2016
by
Dylan Araps
Committed by
GitHub
Dec 02, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #473 from dylanaraps/cache_dir
General: Add cache dir var
parents
cd9b3d10
8193bd63
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
65 deletions
+59
-65
neofetch
neofetch
+59
-65
No files found.
neofetch
View file @
d25de711
...
@@ -921,51 +921,38 @@ get_cpu_usage() {
...
@@ -921,51 +921,38 @@ get_cpu_usage() {
get_gpu
()
{
get_gpu
()
{
case
"
$os
"
in
case
"
$os
"
in
"Linux"
|
"GNU"
)
"Linux"
|
"GNU"
)
# Use cache if it exists
gpu
=
"
$(
PATH
=
"/sbin:
$PATH
"
lspci
-mm
|
awk
-F
'\\"|\\" \\"'
'/Display|3D|VGA/ {print $3 " " $4}'
)
"
if
[[
-f
"/tmp/neofetch/gpu"
]]
;
then
source
"/tmp/neofetch/gpu"
case
"
$gpu
"
in
else
*
"advanced"
*
)
gpu
=
"
$(
PATH
=
"/sbin:
$PATH
"
lspci
-mm
|
awk
-F
'\\"|\\" \\"'
'/Display|3D|VGA/ {print $3 " " $4}'
)
"
gpu
=
"
${
gpu
//Intel*
$'
\n
'
}
"
gpu
=
"
${
gpu
/
'[AMD/ATI]'
}
"
case
"
$gpu
"
in
gpu
=
"
${
gpu
/
'[AMD]'
}
"
*
"advanced"
*
)
gpu
=
"
${
gpu
/*\[
}
"
gpu
=
"
${
gpu
//Intel*
$'
\n
'
}
"
gpu
=
"
${
gpu
/\]*
}
"
gpu
=
"
${
gpu
/
'[AMD/ATI]'
}
"
gpu
=
"AMD
$gpu
"
gpu
=
"
${
gpu
/
'[AMD]'
}
"
;;
gpu
=
"
${
gpu
/*\[
}
"
gpu
=
"
${
gpu
/\]*
}
"
gpu
=
"AMD
$gpu
"
;;
*
"nvidia"
*
)
gpu
=
"
${
gpu
//Intel*
$'
\n
'
}
"
gpu
=
"
${
gpu
/*\[
}
"
gpu
=
"
${
gpu
/\]*
}
"
gpu
=
"NVIDIA
$gpu
"
;;
*
"virtualbox"
*
)
*
"nvidia"
*
)
gpu
=
"VirtualBox Graphics Adapter"
gpu
=
"
${
gpu
//Intel*
$'
\n
'
}
"
;;
gpu
=
"
${
gpu
/*\[
}
"
esac
gpu
=
"
${
gpu
/\]*
}
"
gpu
=
"NVIDIA
$gpu
"
;;
[[
"
$gpu
"
=
~
"intel"
]]
&&
\
*
"virtualbox"
*
)
gpu
=
"Intel Integrated Graphics"
gpu
=
"VirtualBox Graphics Adapter"
;;
esac
cache
"gpu"
"
$gpu
"
"/tmp"
[[
"
$gpu
"
=
~
"intel"
]]
&&
\
fi
gpu
=
"Intel Integrated Graphics"
;;
;;
"Mac OS X"
)
"Mac OS X"
)
# Use cache if it exists
gpu
=
"
$(
system_profiler SPDisplaysDataType |
awk
-F
': '
'/^\ *Chipset Model:/ {printf $2 ", "}'
)
"
if
[[
-f
"/Library/Caches/neofetch/gpu"
]]
;
then
gpu
=
"
${
gpu
//
'/ $'
}
"
source
"/Library/Caches/neofetch/gpu"
gpu
=
"
${
gpu
%,*
}
"
else
gpu
=
"
$(
system_profiler SPDisplaysDataType |
awk
-F
': '
'/^\ *Chipset Model:/ {printf $2 ", "}'
)
"
gpu
=
"
${
gpu
//
'/ $'
}
"
gpu
=
"
${
gpu
%,*
}
"
cache
"gpu"
"
$gpu
"
"/Library/Caches/"
fi
;;
;;
"iPhone OS"
)
"iPhone OS"
)
...
@@ -1030,6 +1017,8 @@ get_gpu() {
...
@@ -1030,6 +1017,8 @@ get_gpu() {
gpu
=
"
${
gpu
/NVIDIA
}
"
gpu
=
"
${
gpu
/NVIDIA
}
"
gpu
=
"
${
gpu
/Intel
}
"
gpu
=
"
${
gpu
/Intel
}
"
fi
fi
cache
"gpu"
"
$gpu
"
}
}
get_memory
()
{
get_memory
()
{
...
@@ -1738,30 +1727,20 @@ get_local_ip() {
...
@@ -1738,30 +1727,20 @@ get_local_ip() {
}
}
get_public_ip
()
{
get_public_ip
()
{
# Use cache if available
if
type
-
p dig
>/
dev/null
;
then
if
[[
-
f
"/tmp/neofetch/public_ip"
]]
;
then
public_ip
=
"
$(
dig +time
=
1 +tries
=
1 +short myip.opendns.com @resolver1.opendns.com
)
"
source
"/tmp/neofetch/public_ip"
[[
"
$public_ip
"
=
~
^
\;
]]
&&
unset
public_ip
elif
[[
-
f
"/Library/Caches/neofetch/public_ip"
]]
;
then
fi
source
"/Library/Caches/neofetch/public_ip"
else
if
type
-
p dig
>/
dev/null
;
then
public_ip
=
"
$(
dig +time
=
1 +tries
=
1 +short myip.opendns.com @resolver1.opendns.com
)
"
[[
"
$public_ip
"
=
~
^
\;
]]
&&
unset
public_ip
fi
if
[[
-
z
"
$public_ip
"
]]
&&
type
-
p curl
>/
dev/null
;
then
if
[[
-
z
"
$public_ip
"
]]
&&
type
-
p curl
>/
dev/null
;
then
public_ip
=
"
$(
curl
--max-time
10
-w
'\n'
"
$public_ip_host
"
)
"
public_ip
=
"
$(
curl
--max-time
10
-w
'\n'
"
$public_ip_host
"
)
"
fi
fi
if
[[
-
z
"
$public_ip
"
]]
&&
type
-
p wget
>/
dev/null
;
then
if
[[
-
z
"
$public_ip
"
]]
&&
type
-
p wget
>/
dev/null
;
then
public_ip
=
"
$(
wget
-T
10
-qO-
"
$public_ip_host
"
)
"
public_ip
=
"
$(
wget
-T
10
-qO-
"
$public_ip_host
"
)
"
fi
fi
fi
case
"
$os
"
in
cache
"public_ip"
"
$public_ip
"
"Mac OS X"
*
)
cache
"public_ip"
"
$public_ip
"
"/Library/Caches"
;;
*
)
cache
"public_ip"
"
$public_ip
"
"/tmp"
;;
esac
}
}
get_users
()
{
get_users
()
{
...
@@ -2364,11 +2343,16 @@ info() {
...
@@ -2364,11 +2343,16 @@ info() {
#
$1
is the subtitle
#
$1
is the subtitle
subtitle="
$1
"
subtitle="
$1
"
# Call the function and update variable
# Use cache if it exists
"
get_
${
2
:-
$1
}
" 2>/dev/null
if [[ -f "
${
cache_dir
}
/neofetch/
${
2
}
" ]]; then
output="
${
2
:-
$1
}
"
source "
${
cache_dir
}
/neofetch/
${
2
}
"
else
# Call the function.
"
get_
${
2
:-
$1
}
" 2>/dev/null
fi
# Trim whitespace
# Update the variable
output="
${
2
:-
$1
}
"
output="
$(
trim
"
${
!output
}
"
)
"
output="
$(
trim
"
${
!output
}
"
)
"
# If prin was used in the function, stop here.
# If prin was used in the function, stop here.
...
@@ -2816,8 +2800,17 @@ bar() {
...
@@ -2816,8 +2800,17 @@ bar() {
}
}
cache
()
{
cache
()
{
mkdir
-p
"
$3
/neofetch"
if
[[
"
$2
"
]]
;
then
printf
"%s"
"
${
1
/*-
}
=
\"
$2
\"
"
>
"
$3
/neofetch/
${
1
/*-
}
"
mkdir
-p
"
${
cache_dir
}
/neofetch"
printf
"%s"
"
${
1
/*-
}
=
\"
$2
\"
"
>
"
${
cache_dir
}
/neofetch/
${
1
/*-
}
"
fi
}
get_cache_dir
()
{
case
"
$os
"
in
"Mac OS X"
)
cache_dir
=
"/Library/Caches"
;;
*
)
cache_dir
=
"/tmp"
;;
esac
}
}
kde_config_dir
()
{
kde_config_dir
()
{
...
@@ -3261,6 +3254,7 @@ main() {
...
@@ -3261,6 +3254,7 @@ main() {
# Print the info
# Print the info
old_functions
old_functions
get_cache_dir
print_info 2>/dev/null
print_info 2>/dev/null
# Prompt calculation
# Prompt calculation
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment