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
902976e6
Commit
902976e6
authored
Nov 13, 2016
by
Dylan Araps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Images: Added two new functions to fallback to ascii/off modes
parent
e262e30d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
28 deletions
+42
-28
neofetch
neofetch
+42
-28
No files found.
neofetch
View file @
902976e6
...
@@ -1824,24 +1824,19 @@ get_image_backend() {
...
@@ -1824,24 +1824,19 @@ get_image_backend() {
# Fallback to ascii mode if image isn't a file.
# Fallback to ascii mode if image isn't a file.
if [[ ! -f "
$image
" ]]; then
if [[ ! -f "
$image
" ]]; then
image_backend="
ascii
"
to_ascii "
Image
:
'$image'
doesn
't exist, falling back to ascii mode."
get_ascii 2>/dev/null
err "
Image
:
'$image'
, doesn
't exist, falling back to ascii mode."
return
return
fi
fi
# Set image program.
get_image_program
if [[ -n "$ITERM_PROFILE" ]]; then
get_term_size
image_program="iterm2"
elif [[ "$(tycat 2>/dev/null)" ]]; then
image_program="tycat"
else
# Fallback to ascii mode if terminal size wasn'
t
found.
image_program="w3m"
if [[ -z
"
$term_width
"
]] && ((term_width == 0)); then
to_ascii
"Image: Failed to find terminal window size"
return
fi
fi
get_term_size
get_image_size
get_image_size
make_thumbnail
make_thumbnail
...
@@ -1854,11 +1849,23 @@ get_image_backend() {
...
@@ -1854,11 +1849,23 @@ get_image_backend() {
esac
esac
}
}
get_image_program() {
if [[ -n "
$ITERM_PROFILE
" ]]; then
image_program="
iterm2
"
elif [[ "
$(
tycat 2>/dev/null
)
" ]]; then
image_program="
tycat
"
else
image_program="
w3m
"
fi
}
get_ascii() {
get_ascii() {
if [[ ! -f "
$ascii
" || "
$ascii
" == "
distro
" ]]; then
if [[ ! -f "
$ascii
" || "
$ascii
" == "
distro
" ]]; then
# Error message
# Error message
[[ "
$ascii
" != "
distro
" ]] &&
\
[[ "
$ascii
" != "
distro
" ]] &&
\
[[ ! -f "$ascii" ]] && err "Ascii: Ascii file not found, using distro ascii"
[[ ! -f "
$ascii
" ]] && err "
Ascii: Ascii file not found, using distro ascii
.
"
# Lowercase the distro name
# Lowercase the distro name
if (("
$version
" <= 3)); then
if (("
$version
" <= 3)); then
...
@@ -1889,9 +1896,7 @@ get_ascii() {
...
@@ -1889,9 +1896,7 @@ get_ascii() {
ascii="
$script_dir
/ascii/distro/
${
ascii
/ *
}
"
ascii="
$script_dir
/ascii/distro/
${
ascii
/ *
}
"
else
else
text_padding=
"0"
to_off "
Ascii: Ascii file not found, falling back to text mode.
"
image_backend=
"off"
err
"Ascii: Ascii file not found, falling back to text mode."
return
return
fi
fi
fi
fi
...
@@ -2074,15 +2079,10 @@ get_term_size() {
...
@@ -2074,15 +2079,10 @@ get_term_size() {
fi
fi
fi
fi
# If
$image isn't a file fallback to ascii mode.
# If
the terminal size was found correctly
if
[[
"
$term_width
"
]]
&&
((
term_width
>
0
))
;
then
if
[[
"
$term_width
"
]]
&&
((
term_width
>
0
))
;
then
clear
clear
zws
=
" "
zws
=
" "
else
image_backend
=
"ascii"
get_ascii
err
"Image: Failed to get window size, falling back to ascii mode."
return
fi
fi
}
}
...
@@ -2211,7 +2211,7 @@ display_image() {
...
@@ -2211,7 +2211,7 @@ display_image() {
# appearing in specific terminal emulators.
# appearing in specific terminal emulators.
sleep
0.05
sleep
0.05
printf
"%b
\n
"
"0;1;
$xoffset
;
$yoffset
;
$width
;
$height
;;;;;
$image
\n
4;
\n
3;"
|
\
printf
"%b
\n
"
"0;1;
$xoffset
;
$yoffset
;
$width
;
$height
;;;;;
$image
\n
4;
\n
3;"
|
\
"
$w3m_img_path
"
-bg
"
$background_color
"
>
/dev/null & 2>&1
||
t
ext_padding
=
"0
"
"
$w3m_img_path
"
-bg
"
$background_color
"
>
/dev/null & 2>&1
||
t
o_off
"Images: w3m-img failed to display the image.
"
;;
;;
"iterm2"
)
"iterm2"
)
...
@@ -2224,6 +2224,20 @@ display_image() {
...
@@ -2224,6 +2224,20 @@ display_image() {
esac
esac
}
}
to_ascii
()
{
# This function makes neofetch fallback to ascii mode.
image_backend
=
"ascii"
get_ascii 2>/dev/null
err
"
$1
"
}
to_off
()
{
# This function makes neofetch fallback to off mode.
text_padding
=
"0"
image_backend
=
"off"
err
"
$1
"
}
# SCREENSHOT
# SCREENSHOT
take_scrot
()
{
take_scrot
()
{
...
@@ -2286,7 +2300,7 @@ info() {
...
@@ -2286,7 +2300,7 @@ info() {
# If the output is empty, don't print anything.
# If the output is empty, don't print anything.
[[ -z "
${
output
//
}
" ]] &&
\
[[ -z "
${
output
//
}
" ]] &&
\
err "
Info
:
Couldn
't detect $subtitle" && return
err "
Info
:
Couldn
't detect $subtitle
.
" && return
case "$1" in
case "$1" in
title)
title)
...
@@ -2674,7 +2688,7 @@ get_default_config() {
...
@@ -2674,7 +2688,7 @@ get_default_config() {
fi
fi
if source "
$default_config
"; then
if source "
$default_config
"; then
err "
Config: Sourced default config
(
$default_config
)
"
err "
Config: Sourced default config
.
(
$default_config
)
"
else
else
err "
Config
:
Default config not found, continuing...
"
err "
Config
:
Default config not found, continuing...
"
fi
fi
...
@@ -2684,12 +2698,12 @@ get_user_config() {
...
@@ -2684,12 +2698,12 @@ get_user_config() {
# Check
$config_file
# Check
$config_file
if [[ -f "
$config_file
" ]]; then
if [[ -f "
$config_file
" ]]; then
source "
$config_file
"
source "
$config_file
"
err "
Config
:
Sourced user config (
$config_file
)
"
err "
Config
:
Sourced user config
.
(
$config_file
)
"
return
return
elif [[ "
$config_file
" == "
travis
" ]]; then
elif [[ "
$config_file
" == "
travis
" ]]; then
source "
$travis_config
"
source "
$travis_config
"
err "
Config
:
Sourced user config (
$travis_config
)
"
err "
Config
:
Sourced user config
.
(
$travis_config
)
"
return
return
fi
fi
mkdir -p "
$XDG_CONFIG_HOME
/neofetch/
"
mkdir -p "
$XDG_CONFIG_HOME
/neofetch/
"
...
@@ -2715,7 +2729,7 @@ get_user_config() {
...
@@ -2715,7 +2729,7 @@ get_user_config() {
fi
fi
source "
$config_file
"
source "
$config_file
"
err "
Config
:
Sourced user config (
$config_file
)
"
err "
Config
:
Sourced user config
.
(
$config_file
)
"
}
}
bar() {
bar() {
...
...
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