1
0
mirror of https://github.com/alrayyes/dotfiles/ synced 2023-11-14 15:56:30 +00:00

added multi monitor wallpaper support

This commit is contained in:
Ryan Kes 2019-03-24 17:18:39 +01:00
parent 768a7b62e1
commit b3fdfeb16d
2 changed files with 21 additions and 10 deletions

View File

@ -146,7 +146,8 @@ command! vgrep nvim "+grep %a"
command! reload :write | restart
command! ncdu ncdu %d 2> /dev/null
command! lockwallpaper generate-lock-image.sh %f 2> /dev/null
command! backgroundwallpaper switch-background-image.sh %f 2> /dev/null
command! backgroundwallpaperone switch-background-image.sh %f 1 2> /dev/null
command! backgroundwallpapertwo switch-background-image.sh %f 2 2> /dev/null
" Fuzzy file search
command! FZFfind :set noquickview | :execute 'goto "'.system('find | fzf --height 10 2>/dev/tty ').'"%IU' | redraw
@ -492,7 +493,8 @@ nnoremap <f8> :delete<cr>
" Generate lock wallapaper
nnoremap ,l :lockwallpaper<cr>
" Generate background image wallpaper
nnoremap ,w :backgroundwallpaper<cr>
nnoremap ,w1 :backgroundwallpaperone<cr>
nnoremap ,w2 :backgroundwallpapertwo<cr>
" quit
nnoremap q :q!<cr>

View File

@ -2,16 +2,25 @@
clear
WIDTH=$(xrandr | grep '\*' | awk -F 'x' '{print $1}' | sed 's/ //g')
OUTPUT_IMAGE="$HOME/.cache/wall.png"
if [ "${2}" = "2" ]
then
OUTPUT_IMAGE="$HOME/.cache/wall2.png"
WIDTH=$(xrandr | grep '\*' | sed -n '1p' | awk -F 'x' '{print $2}' | awk -F '_' '{print $1}' | sed 's/ //g')
HEIGHT=$(xrandr | grep '\*' | sed -n '1p' | awk -F 'x' '{print $1}' | sed 's/ //g')
else
OUTPUT_IMAGE="$HOME/.cache/wall1.png"
# Use tail -n 1 to get last monitor so this works with laptop as well
WIDTH=$(xrandr | grep '\*' | tail -n 1 | awk -F 'x' '{print $1}' | sed 's/ //g')
HEIGHT=$(xrandr | grep '\*' | tail -n 1 | awk -F 'x' '{print $2}' | awk '{print $1}' | sed 's/ //g')
fi
echo "Converting ${1} to ${OUTPUT_IMAGE}...."
echo "Converting ${1} to ${OUTPUT_IMAGE}"
convert "${1}" "${OUTPUT_IMAGE}"
echo "done!"
echo "Reszing ${OUTPUT_IMAGE} to width ${WIDTH}...."
convert "${OUTPUT_IMAGE}" -resize "${WIDTH}"x "${OUTPUT_IMAGE}"
echo "Setting background to ${OUTPUT_IMAGE}"
feh --bg-scale ~/.cache/wall.png
echo "Resizing ${OUTPUT_IMAGE} to ${WIDTH}x${HEIGHT}"
convert "${OUTPUT_IMAGE}" -resize "${WIDTH}x${HEIGHT}^" -gravity center -extent "${WIDTH}"x"${HEIGHT}" "${OUTPUT_IMAGE}"
echo "Setting background images...."
feh --bg-scale ~/.cache/wall1.png --bg-scale ~/.cache/wall2.png
echo "done!"