From 1c10c2a04c8689f237f1c1f180216785d411f070 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Wed, 27 Jul 2022 01:53:10 -0400 Subject: [PATCH] . --- bash_tools.sh | 31 ++----------------------------- bash_tools/wallpaper.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 bash_tools/wallpaper.sh 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