Skip to content

Commit

Permalink
Added primary display detection
Browse files Browse the repository at this point in the history
Resolution should be selected based on the primary display as there might be multiple displays present.
This also solves the issue of the monitor interface being different for each system while it was hardcoded in the old commit for a specific use case that
would only work for a handful of users who use mainly laptops or other more integrated devices.

This commit adds a function to find the current primary display and uses it for getting the screen resolution to be used when rendering the wallpaper and when setting the rendered wallpaper to the screen

Fixes issue #1
  • Loading branch information
jNullj committed Jul 22, 2022
1 parent f452735 commit 929467f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fox-neat-wallpaper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"

# functions to refresh/update global veriables about the user/system

get_primary_display () {
xfconf-query -c displays -p /Default -lv | grep "Primary" | grep "true" | cut -d "/" -f3
}

get_display_resolution () {
IMAGE_SIZE=$(xfconf-query -c displays -p /Default/eDP/Resolution)
local PRIMARY_DISPLAY=$(get_primary_display)
IMAGE_SIZE=$(xfconf-query -c displays -p "/Default/$PRIMARY_DISPLAY/Resolution")
IMAGE_SIZE_X=$(echo $IMAGE_SIZE | cut -d'x' -f1)
IMAGE_SIZE_Y=$(echo $IMAGE_SIZE | cut -d'x' -f2)
}
Expand Down Expand Up @@ -89,9 +94,10 @@ generate_wallpaper () {

# set xfce4 wallpaper for user using xfconf-query
set_wallpaper () {
local PRIMARY_DISPLAY=$(get_primary_display)
xfconf-query \
--channel xfce4-desktop \
--property /backdrop/screen0/monitoreDP/workspace0/last-image \
--property "/backdrop/screen0/monitor${PRIMARY_DISPLAY}/workspace0/last-image" \
--set $WALLPAPER_PATH/$IMG_NAME
}

Expand Down

0 comments on commit 929467f

Please sign in to comment.