Skip to content

Commit

Permalink
Fix #89: Options to select fit size / wallpaper mode. Image-dependent…
Browse files Browse the repository at this point in the history
… smart fit. (#518)

* Split overloaded UI pages into separate pages

* Add options and UI for auto-rotate and display mode

* Add logic to run auto-rotate and display-mode related commands

* Pluginize the display modes

* Revert changes to set_wp_throttled

* Implement "Smart" display mode that depends on image size

* Faster Heavy and Soft blur filters

* Smart mode: Add logic to use "spanned" when image ratio close to total screen size

* Add a comment in set_wallpaper
  • Loading branch information
peterlevi authored Jun 16, 2022
1 parent 45b22b0 commit 8ee5eea
Show file tree
Hide file tree
Showing 17 changed files with 1,573 additions and 930 deletions.
21 changes: 11 additions & 10 deletions data/config/filters.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# These are automatically appended to the user's filters.
# New default filters should be added here, as well as in the default config so that existing users will also see them
# (they already have a config file, so the default config is not used for them)

False|Keep original|
False|Grayscale|-type Grayscale
False|Heavy blur|-blur 120x40
False|Oil painting|-paint 8
False|Pointilism|-spread 10 -noise 3
False|Pixellate|-scale 3% -scale 3333%
# These are automatically appended to the user's filters.
# New default filters should be added here, as well as in the default config so that existing users will also see them
# (they already have a config file, so the default config is not used for them)

False|Keep original|
False|Grayscale|-type Grayscale
False|Heavy blur|-scale 20% -blur 0x10 -resize 500%
False|Soft blur|-scale 20% -blur 0x2 -resize 500%
False|Oil painting|-paint 8
False|Pointilism|-spread 10 -noise 3
False|Pixellate|-scale 3% -scale 3333%
12 changes: 10 additions & 2 deletions data/config/variety.conf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ favorites_folder = ~/.config/variety/Favorites
# Move to Favorites is only shown when the user has write permissions over the file, otherwise we fallback to Copy
favorites_operations = Downloaded:Copy;Fetched:Move;Others:Copy

# wallpaper_auto_rotate = <True or False>
wallpaper_auto_rotate = False

# wallpaper_display_mode = <"os" |
# "smart" | "zoom" | "fill-with-black" | "fill-with-blur" |
# "gnome-zoom" | "gnome-centered" | "gnome-scaled" | "gnome-stretched" | "gnome-spanned", "gnome-wallpaper">
wallpaper_display_mode = "os"

# fetch_folder = <some folder> - when not specified, the default is ~/.config/variety/Fetched
fetched_folder = ~/.config/variety/Fetched

Expand Down Expand Up @@ -221,8 +229,8 @@ src11 = True|flickr|user:www.flickr.com/photos/peter-levi/;user_id:93647178@N00;
[filters]
filter1 = False|Keep original|
filter2 = False|Grayscale|-type Grayscale
filter3 = False|Heavy blur|-blur 120x40
filter4 = False|Soft blur|-blur 20x7
filter3 = False|Heavy blur|-scale 20% -blur 0x10 -resize 500%
filter4 = False|Soft blur|-scale 20% -blur 0x2 -resize 500%
filter5 = False|Oil painting|-paint 8
filter6 = False|Pointilism|-spread 10 -noise 3
filter7 = False|Pixellate|-scale 3% -scale 3333%
34 changes: 27 additions & 7 deletions data/scripts/set_wallpaper
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
#
# $3: The third passed parameter is the absolute path to the original wallpaper image (before effects, clock, etc.)
#
# $4: Fourth parameter comes from the display mode setting: "os" means that set_wallpaper should try to
# leave the OS setting unchanged. "zoom" means to try to fill the screen fully with the provided image.
# Other parameters that could be passed are the scaling modes used by GNOME:
# "centered", "scaled", "stretched", "zoom", "spanned", "wallpaper"
# TODO: Ideally all sections below for different DEs would take this setting into account
#
# EXAMPLE:
# echo "$1" # /home/username/.config/variety/wallpaper/wallpaper-clock-fac0eef772f9b03bd9c0f82a79d72506.jpg
# echo "$2" # auto
Expand Down Expand Up @@ -168,20 +174,28 @@ fi
# Gnome 3, Unity
gsettings set org.gnome.desktop.background picture-uri "file://$WP" 2> /dev/null
gsettings set org.gnome.desktop.background picture-uri-dark "file://$WP" 2> /dev/null
if [ "$(gsettings get org.gnome.desktop.background picture-options)" == "'none'" ]; then
if [[ "$4" =~ ^(wallpaper|centered|scaled|stretched|zoom|spanned)$ ]]; then
gsettings set org.gnome.desktop.background picture-options "$4"
fi
if [ "$(gsettings get org.gnome.desktop.background picture-options)" == "'none'" ]; then
gsettings set org.gnome.desktop.background picture-options 'zoom'
fi

# GNOME Screensaver / Lock screen - thanks to George C. de Araujo for the patch
gsettings set org.gnome.desktop.screensaver picture-uri "file://$WP" 2> /dev/null
if [[ "$4" =~ ^(wallpaper|centered|scaled|stretched|zoom|spanned)$ ]]; then
gsettings set org.gnome.desktop.screensaver picture-options "$4"
fi
if [ "$(gsettings get org.gnome.desktop.screensaver picture-options)" == "'none'" ]; then
gsettings set org.gnome.desktop.screensaver picture-options 'zoom'
fi


# Deepin
if [ "$(gsettings list-schemas | grep -c com.deepin.wrap.gnome.desktop.background)" -ge 1 ]; then
gsettings set com.deepin.wrap.gnome.desktop.background picture-uri "file://$WP"
if [[ "$4" =~ ^(wallpaper|centered|scaled|stretched|zoom|spanned)$ ]]; then
gsettings set com.deepin.wrap.gnome.desktop.background picture-options "$4"
fi
if [ "$(gsettings get com.deepin.wrap.gnome.desktop.background picture-options)" == "'none'" ]; then
gsettings set com.deepin.wrap.gnome.desktop.background picture-options 'zoom'
fi
Expand Down Expand Up @@ -215,8 +229,10 @@ SIMPLE_WMS=("bspwm" "dwm" "herbstluftwm" "i3" "i3-with-shmlog" "jwm" "LeftWM" "o
if [[ " ${SIMPLE_WMS[*]} " = *" $XDG_CURRENT_DESKTOP "* || " ${SIMPLE_WMS[*]} " = *" $XDG_SESSION_DESKTOP "* ||
" ${SIMPLE_WMS[*]} " = *" $DESKTOP_SESSION "* ]]; then
if command -v "feh" >/dev/null 2>&1; then
# TODO: This should take the scaling parameter $4 into account and use other options than --bg-fill
feh --bg-fill "$WP" 2> /dev/null
elif command -v "nitrogen" >/dev/null 2>&1; then
# TODO: This should take the scaling parameter $4 into account and use other options than --set-zoom-fill
nitrogen --set-zoom-fill --save "$WP" 2> /dev/null
fi
fi
Expand Down Expand Up @@ -246,12 +262,21 @@ fi

# MATE after 1.6
gsettings set org.mate.background picture-filename "$WP" 2> /dev/null
if [ "$(gsettings get org.mate.desktop.background picture-options 2>/dev/null)" == "'none'" ]; then
gsettings set org.mate.desktop.background picture-options 'zoom'
fi
if [[ "$4" =~ ^(wallpaper|centered|scaled|stretched|zoom|spanned)$ ]]; then
gsettings set org.mate.desktop.background picture-options "$4"
fi

# Cinnamon after 2.0
gsettings set org.cinnamon.desktop.background picture-uri "file://$WP" 2> /dev/null
if [ "$(gsettings get org.cinnamon.desktop.background picture-options 2>/dev/null)" == "'none'" ]; then
gsettings set org.cinnamon.desktop.background picture-options 'zoom'
fi
if [[ "$4" =~ ^(wallpaper|centered|scaled|stretched|zoom|spanned)$ ]]; then
gsettings set org.cinnamon.desktop.background picture-options "$4"
fi

# Awesome Window Manager
# Be sure to start variety when you start awesome, such as by adding it to ~/.xinitrc
Expand All @@ -263,9 +288,4 @@ fi

# =====================================================================================

# OPTIONAL: Show a notification on automatic wallpaper change.
# Display the original filename in the notification, but actually apply the post-effects image.
# name=$(echo "$3" | sed 's/\//\n/g'| tail -n 1)
# if [ "$2" == "auto" ]; then notify-send --icon "$WP" "Wallpaper changed" "$name" ; fi

exit 0
Loading

0 comments on commit 8ee5eea

Please sign in to comment.