From 7b8cfad22b0d5ce039a2fdcee818d21302587c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ceylan=20Bozo=C4=9Fullar=C4=B1ndan?= Date: Fri, 15 Feb 2019 16:44:46 +0300 Subject: [PATCH] Changed again. --- .scripts/tools/setbg | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.scripts/tools/setbg b/.scripts/tools/setbg index 9743c137..952dd795 100755 --- a/.scripts/tools/setbg +++ b/.scripts/tools/setbg @@ -1,16 +1,15 @@ #!/bin/sh # Sets the background. -# If given an argument with -u flag, will download file from given url and set the file as background. +# If given an argument with -u flag, will check the file from given url whether it is an image or not. If the file is an image then it sets the file as background. # Without -u flag, will set local file as backgound. if [ "$1" == "-u" ]; then - curl -o ~/.config/wall-temp.png "$2" - type="$(file -b ~/.config/wall-temp.png --mime-type | sed s/[/].*$//)" + type="$(curl -sI $2 | sed -En 's/^Content-Type: (.*)\/(.*)/\1/p')" if [ "$type" == "image" ]; then - mv ~/.config/wall-temp.png ~/.config/wall.png + curl -o ~/.config/wall.png "$2" xwallpaper --maximize ~/.config/wall.png else - rm ~/.config/wall-temp.png + echo "Not an image!" fi else [ ! -z "$1" ] && cp "$1" ~/.config/wall.png && notify-send -i "$HOME/.config/wall.png" "Wallpaper changed."