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
194c7b50
Commit
194c7b50
authored
Oct 31, 2016
by
Dylan Araps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Images: Use \033[14t before falling back to external programs
parent
60318bc1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
50 deletions
+48
-50
neofetch
neofetch
+48
-50
No files found.
neofetch
View file @
194c7b50
...
...
@@ -1964,67 +1964,65 @@ getimage() {
;;
esac
# Get terminal width and height
if type -p xdotool >/dev/null 2>&1 &&
\
[ "
$image_backend
" != "
iterm2
" ]; then
current_window="
$(
xdotool getactivewindow
)
"
eval "
$(
xdotool getwindowgeometry
--shell
"
$current_window
"
)
"
term_height="
$HEIGHT
"
term_width="
$WIDTH
"
elif type -p xwininfo >/dev/null 2>&1 &&
\
type -p xdpyinfo >/dev/null 2>&1 ||
\
type -p xprop >/dev/null 2>&1 &&
\
[ "
$image_backend
" != "
iterm2
" ]; then
if type -p xdpyinfo >/dev/null 2>&1; then
current_window="
$(
xdpyinfo |
grep
focus |
grep
-E
-o
0x[0-9a-f]+
)
"
elif type -p xprop >/dev/null 2>&1; then
current_window="
$(
xprop
-root
|
awk
'/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}'
)
"
fi
if [ -n "
$TMUX
" ]; then
printf "
%b%s
" "
\0
33Ptmux
;
\0
33
\0
33[14t
\0
33
\0
33[c
\0
33
\\
"
read_flags="
-d
c
"
term_size="
$(
xwininfo
-id
"
$current_window
"
|
awk
-F
': '
'/Width|Height/ {printf $2 " "}'
)
"
term_width="
${
term_size
/ *
}
"
term_height="
${
term_size
/
${
term_width
}}
"
elif [ "
$image_backend
" == "
tycat
" ]; then
printf "
%b%s
" "
\0
33
}
qs
\0
00
"
else
if [ -n "
$TMUX
" ]; then
printf "
%b%s
" "
\0
33Ptmux
;
\0
33
\0
33[14t
\0
33
\0
33[c
\0
33
\\
"
read_flags="
-d
c
"
printf "
%b%s
" "
\0
33[14t
\0
33[c
"
read_flags="
-d
c
"
fi
elif [ "
$image_backend
" == "
tycat
" ]; then
printf "
%b%s
" "
\0
33
}
qs
\0
00
"
# The escape code above prints the output AFTER the prompt so this
builtin read -s -t 1
${
read_flags
}
-r term_size
else
printf "
%b%s
" "
\0
33[14t
\0
33[c
"
read_flags="
-d
c
"
fi
# Split the string
if [ "
$image_backend
" == "
tycat
" ]; then
term_size=(
${
term_size
//;/
}
)
term_width="
$((
term_size[2]
*
term_size[0]
))
"
term_height="
$((
term_size[3]
*
term_size[1]
))
"
# The escape code above prints the output AFTER the prompt so this
builtin read -s -t 1
${
read_flags
}
-r term_size
else
term_size="
${
term_size
//
'['
}
"
term_size="
${
term_size
/
';'
}
"
term_size="
${
term_size
/
$'
\E
4'
}
"
term_size="
${
term_size
/t*
}
"
term_height="
${
term_size
/
';'
*
}
"
term_width="
${
term_size
/*
';'
}
"
fi
# Split the string
if [ "
$image_backend
" == "
tycat
" ]; then
term_size=(
${
term_size
//;/
}
)
term_width="
$((
term_size[2]
*
term_size[0]
))
"
term_height="
$((
term_size[3]
*
term_size[1]
))
"
# Get terminal width and height if
\0
33[14t is unsupported.
if [ "
${#
term_size
}
" -le 5 ] && [ "
$image_backend
" != "
tycat
" ]; then
if type -p xdotool >/dev/null 2>&1 &&
\
[ "
$image_backend
" != "
iterm2
" ]; then
current_window="
$(
xdotool getactivewindow
)
"
eval "
$(
xdotool getwindowgeometry
--shell
"
$current_window
"
)
"
term_height="
$HEIGHT
"
term_width="
$WIDTH
"
elif type -p xwininfo >/dev/null 2>&1 &&
\
type -p xdpyinfo >/dev/null 2>&1 ||
\
type -p xprop >/dev/null 2>&1 &&
\
[ "
$image_backend
" != "
iterm2
" ]; then
if type -p xdpyinfo >/dev/null 2>&1; then
current_window="
$(
xdpyinfo |
grep
focus |
grep
-E
-o
0x[0-9a-f]+
)
"
elif type -p xprop >/dev/null 2>&1; then
current_window="
$(
xprop
-root
|
awk
'/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}'
)
"
fi
else
term_size="
${
term_size
//
'['
}
"
term_size="
${
term_size
/
';'
}
"
term_size="
${
term_size
/
$'
\E
4'
}
"
term_size="
${
term_size
/t*
}
"
term_height="
${
term_size
/
';'
*
}
"
term_width="
${
term_size
/*
';'
}
"
term_size="
$(
xwininfo
-id
"
$current_window
"
|
awk
-F
': '
'/Width|Height/ {printf $2 " "}'
)
"
term_width="
${
term_size
/ *
}
"
term_height="
${
term_size
/
${
term_width
}}
"
fi
[ "
${#
term_size
}
" -le 5 ] && no_esc="
1
"
fi
# If
$img
isn't a file or the terminal doesn't support xterm escape sequences,
# fallback to ascii mode.
if [ ! -f "
$img
" ] || [ "
$term_width
" -le 10 ] || ([ "
$no_esc
" == 1 ] && [ "
$image_backend
" != "
tycat
" ]); then
# If
$img
isn't a file fallback to ascii mode.
if [ ! -f "
$img
" ] || [ "
$term_width
" -le 10 ]; then
image="
ascii
"
getascii
...
...
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