diff --git a/bash_tools.sh b/bash_tools.sh index df34e8e..e7864dd 100644 --- a/bash_tools.sh +++ b/bash_tools.sh @@ -48,35 +48,8 @@ function dict(){ python $DOTFILE_DIR/bash_tools/dict.py $1 $2 } -# Linux specific functions -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - -function set_wallpaper(){ - local file=$1 - # convert to abs path - if [[ ! "$file" = /* ]]; then - file=$(pwd)/$1 - fi - gsettings set org.gnome.desktop.background picture-uri file://$file -} - -fi - -# Mac OSX specific functions -if [[ "$OSTYPE" == "darwin"* ]]; then - -function set_wallpaper(){ - local file=$1 - # convert to abs path - if [[ ! "$file" = /* ]]; then - file=$(pwd)/$1 - fi - - apple_script_single_desk="tell application \"Finder\" to set desktop picture to POSIX file \"$file\"" - osascript -e "$apple_script_single_desk" -} - -fi +# set_wallpaper() function +source $DOTFILE_DIR/bash_tools/wallpaper.sh # # Command Configuration diff --git a/bash_tools/wallpaper.sh b/bash_tools/wallpaper.sh new file mode 100644 index 0000000..198753b --- /dev/null +++ b/bash_tools/wallpaper.sh @@ -0,0 +1,35 @@ + +# Linux specific functions +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + +set_gnome_wp() { + gsettings set org.gnome.desktop.background picture-uri "file://$1" + gsettings set org.gnome.desktop.background picture-uri-dark "file://$1" +} + +function set_wallpaper(){ + local file=$1 + # convert to abs path + if [[ ! "$file" = /* ]]; then + file=$(pwd)/$1 + fi + set_gnome_wp $file +} + +fi + +# Mac OSX specific functions +if [[ "$OSTYPE" == "darwin"* ]]; then + +function set_wallpaper(){ + local file=$1 + # convert to abs path + if [[ ! "$file" = /* ]]; then + file=$(pwd)/$1 + fi + + apple_script_single_desk="tell application \"Finder\" to set desktop picture to POSIX file \"$file\"" + osascript -e "$apple_script_single_desk" +} + +fi