You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					74 lines
				
				1.7 KiB
			
		
		
			
		
	
	
					74 lines
				
				1.7 KiB
			| 
											10 years ago
										 | #!/bin/bash
 | ||
|  | 
 | ||
|  | #Создан:  Пт 29 янв 2016 11:11:27
 | ||
|  | #Изменён: Пт 29 янв 2016 12:54:41
 | ||
|  | 
 | ||
|  | # Идея z3bra -- 2014-01-21: http://blog.z3bra.org/2014/01/images-in-terminal.html
 | ||
|  | # Доработка envrm
 | ||
|  | 
 | ||
|  | W3MIMGDISPLAY="/usr/libexec/w3m/w3mimgdisplay"
 | ||
|  | FONTH=12 # Size of one terminal row
 | ||
|  | FONTW=8  # Size of one terminal column
 | ||
|  | COLUMNS=`tput cols`
 | ||
|  | LINES=`tput lines`
 | ||
|  | 
 | ||
|  | #Все позиции захардкорены
 | ||
|  | posx[1]=10; posx[2]=205; posx[3]=400; posx[4]=600; posx[5]=800; posx[6]=1000
 | ||
|  | posy[1]=45; posy[2]=200; posy[3]=350; posy[4]=500; posy[5]=800; posy[6]=1000
 | ||
|  | text[1]=18; text[2]=36; text[3]=54; text[4]=72; text[5]=90; text[6]=111
 | ||
|  | 
 | ||
|  | row[1]=0; row[2]=100; row[3]=200; row[4]=300; row[5]=300
 | ||
|  | 
 | ||
|  | x=1
 | ||
|  | y=1
 | ||
|  | img=1
 | ||
|  | images=24
 | ||
|  | 
 | ||
|  | clear
 | ||
|  | echo -e "\n \033[1;32m$(pwd):\033[00m"
 | ||
|  | 
 | ||
|  | for FILENAME in ${*:-*}; {
 | ||
|  | 	#Обработка только изображений
 | ||
|  | 	file "$FILENAME" | grep 'JPEG|PNG|GIF' 2>&1 >/dev/null
 | ||
|  | 
 | ||
|  | 	if [ $? -eq 0 ]; then
 | ||
|  | 		read width height <<< `echo -e "5;$FILENAME" | $W3MIMGDISPLAY`
 | ||
|  | 
 | ||
|  | 		max_width=$(($FONTW * $COLUMNS))
 | ||
|  | 		max_height=$(($FONTH * $(($LINES - 2)))) # substract one line for prompt
 | ||
|  | 
 | ||
|  | 		if test $width -gt $max_width; then
 | ||
|  | 			height=$(($height * $max_width / $width))
 | ||
|  | 			width=$max_width
 | ||
|  | 		fi
 | ||
|  | 
 | ||
|  | 		if test $height -gt $max_height; then
 | ||
|  | 			width=$(($width * $max_height / $height))
 | ||
|  | 			height=$max_height
 | ||
|  | 		fi
 | ||
|  | 
 | ||
|  | 		width=$((width / 4))
 | ||
|  | 		height=$((height / 4))
 | ||
|  | 
 | ||
|  | 		w3m_command="0;1;${posx[x]};${posy[y]};$width;$height;;;;;$FILENAME\n4;\n3;"
 | ||
|  | 
 | ||
|  | 		tput cup $((($height+${row[y]})/$FONTH)) ${text[$((x-1))]}
 | ||
|  | 		echo " $FILENAME"
 | ||
|  | 		echo -n -e $w3m_command|$W3MIMGDISPLAY
 | ||
|  | 
 | ||
|  | 		if [ $x -eq 6 ]; then
 | ||
|  | 			x=1
 | ||
|  | 			y=$((y + 1))
 | ||
|  | 		else
 | ||
|  | 			x=$((x + 1))
 | ||
|  | 		fi
 | ||
|  | 
 | ||
|  | 		if [ $img -eq $images ]; then
 | ||
|  | 			exit
 | ||
|  | 		else
 | ||
|  | 			img=$((img + 1))
 | ||
|  | 		fi
 | ||
|  | 	fi
 | ||
|  | }
 | ||
|  | 
 |