You are not logged in.

#26 2017-11-17 16:46:35

misko_2083
Member
Registered: 2016-05-24
Posts: 93

Re: Set backgrounds for each workspace and/or monitor in Openbox

xaos52 wrote:

Nice script, damo, BUT:
seems like there is an unresolved 'memory leak' bug against running xprop -spy for extended periods if time.

My guess is that xprop is/was mostly used for debugging purposes. Hence no-one is really interested in fixing it. Not the Debian developers, nor upstream.

EDIT:
It is not clear from the bug report whether it is just

xprop -spy

- spying on all variables - that causes problems.
Could be that monitoring just one value is OK.

I've removed xprop -spy just in case.
Do you know if xev has any memory leaks? smile
This is the method used in the script:
xev monitors for root window property change events

xev -root -event property

If _NET_CURRENT_DESKTOP property is changed
script checks the current with xprop -root

CURR_DESKTOP=$(xprop -root _NET_CURRENT_DESKTOP)

The rest of script is the same >

#!/bin/bash
#
# Script to enable different wallpapers on each workspace and monitor with Openbox
# Written by damo <damo@bunsenlabs.org> November 2015
#
# When first run, the script writes a configuration file template. The user can
# then edit this and add the image filepaths.
#
# To run while logged in, add "wallpapersd &" to your autostart
#
# REQUIRES: 'feh'
###############################################################################

WALLS_FILE="$HOME/.config/wallpapers.cfg"
FEH_CMD="feh --bg-fill" # edit this, or wallpapers.cfg, to use a different feh command

TXT="# Add filepaths to the images to be set as backgrounds on each workspace.
# You can have an image set for each monitor.
# Commands should be in the form:
#  $FEH_CMD 'path/to/image1(monitor 1)' 'path/to/image2(monitor 2)' etc
#
# From man feh:
# For the --bg-center and --bg-max options, you can use the --geometry option to
# specify an offset from one side of the screen instead of centering the image.
# Positive values will offset from the left/top side, negative values from the
# bottom/right.  +0 and -0 are both valid and distinct values.
#
# Note that all options except --bg-tile support Xinerama.  For instance,
# if you have multiple screens connected and use e.g.  --bg-center, feh will
# center or appropriately offset the image on each screen.  You may even specify 
# more than one file, in that case, the first file is set on screen 0, the second
# on screen 1, and so on.
#
# Use --no-xinerama to treat the whole X display as one screen when setting wallpapers.
#     --bg-center
#         Center the file on the background.  If it is too small, it will be
#         surrounded by a black border
#     --bg-fill
#         Like --bg-scale, but preserves aspect ratio by zooming the image until
#         it fits.  Either a horizontal or a vertical part of the image will be cut off
#     --bg-max
#         Like --bg-fill, but scale the image to the maximum size that fits the
#         screen with black borders on one side.
#     --bg-scale
#         Fit the file into the background without repeating it, cutting off stuff
#         or using borders.  But the aspect ratio is not preserved either
#     --bg-tile
#         Tile (repeat) the image in case it is too small for the screen
#
###########################################################################"

USAGE="USAGE:

  wallpapersd &   Runs the 'daemon' to set per-workspace backgrounds.
                  First run will open wallpapers.cfg, which has instructions and feh settings.
  
  --config        Open wallpapers.cfg for editing
  
  -h,--help       This help
"

if ! hash feh;then
    echo "feh is required to set the backgrounds. Install the feh package then re-run the script"
    exit 1
fi

case "$1" in
    -h|--help ) echo -e "\n$USAGE"
                exit
                ;;
    --config  ) if [[ -f $WALLS_FILE ]] &>/dev/null;then
                    echo -e "\n  Open wallpapers.cfg for editing?\n  (wallpapersd needs to be restarted afterwards) y|N"
                    read -srn1 RET
                    case $RET in
                        n|N ) exit;;
                        y|Y ) xdg-open "$WALLS_FILE" &  # open cfg file for editing
                              killall wallpapersd
                              exit
                              ;;
                        *   ) exit
                              ;;
                    esac
                else
                    echo -e "  No ~/.config/wallpapers.cfg found\n  Run wallpapersd first? Y|n?"
                    read -srn1 ANS
                    case $ANS in
                        n|N ) exit
                              ;;
                        *   ) wallpapersd 2>/dev/null & # run app to generate cfg template
                              xdg-open "$WALLS_FILE" &  # open cfg file for editing
                              ;;
                    esac
                fi
                ;;
esac

if [[ ! -f $WALLS_FILE ]];then
    echo -e "$TXT\n" > "$WALLS_FILE"
    NUM_DESKTOPS=$(xprop -root _NET_NUMBER_OF_DESKTOPS)
    NUM_DESKTOPS=${NUM_DESKTOPS:(-1)}
    for (( i=0; i < $NUM_DESKTOPS; i++ ));do
        echo "[DESKTOP_$i] $FEH_CMD " >> "$WALLS_FILE"
    done
    xdg-open "$WALLS_FILE"  # open cfg file for editing. Script must be restarted afterwards.
    exit
else
    xev -root -event property |  # <-- this is the watching process
        while IFS=$',' read -a W;do
            if [[ "${W[0]}" =~ '_NET_CURRENT_DESKTOP' ]]; then
	        CURR_DESKTOP=$(xprop -root _NET_CURRENT_DESKTOP)
                CURR_DESKTOP=${CURR_DESKTOP:(-1)}
                while read DTOP CMD;do
                    VAL="[DESKTOP_$CURR_DESKTOP]"
                    if [[ "$DTOP" = "$VAL" ]];then
                        eval $CMD
                    fi
                done < "$WALLS_FILE"
             fi
             W=()
        done  
fi

Last edited by misko_2083 (2017-11-17 17:02:20)

Offline

#27 2018-09-05 10:16:09

Ka6aH4iK
New Member
Registered: 2018-09-05
Posts: 1

Re: Set backgrounds for each workspace and/or monitor in Openbox

I have problem with starting script.

./wallpapersd: line 99: syntax error near unexpected token `killall'
./wallpapersd: line 99: `                              killall wallpapersd'

Offline

#28 2018-09-05 15:58:17

damo
....moderator....
Registered: 2015-08-20
Posts: 4,378

Re: Set backgrounds for each workspace and/or monitor in Openbox

Line #99 should be...

    NUM_DESKTOPS=$(xprop -root _NET_NUMBER_OF_DESKTOPS)

Did you copy and paste the code properly?


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#29 2018-11-02 07:03:53

cherkie
Member
Registered: 2018-08-09
Posts: 64

Re: Set backgrounds for each workspace and/or monitor in Openbox

damo wrote:

If you just want to set backgrounds for different monitors then what is the problem? Just use Nitrogen.


How can one achieve this?

This is my bg-saved.cfg

[xin_-1]
file=/home/albert/Pictures/wallpapers/think.jpg
mode=1
bgcolor=#001e44

[:0.0]
file=/home/albert/Pictures/wallpapers/think.jpg
mode=5
bgcolor=#000000

and this is my nitrogen.cfg

[geometry]
posx=3186
posy=173
sizex=450
sizey=500

[nitrogen]
view=list
recurse=true
sort=alpha
icon_caps=false
dirs=/home/albert/Pictures/wallpapers;

This is my xrandr

xrandr --output DVI-D-0 --primary --mode 1920x1080 --pos 1920x0 --rotate normal  --output DVI-I-0 --mode 1360x768 --pos 0x0 --scale-from 1912x1080 --rotate normal & 

I am lost my current wallpaper stretches over two desktops and it is a quote and it looks... shit. lol

Offline

#30 2018-11-02 12:00:53

damo
....moderator....
Registered: 2015-08-20
Posts: 4,378

Re: Set backgrounds for each workspace and/or monitor in Openbox

Your bg-saved.cfg is using an old format. Which version of BL are you using?

FWIW here is my bg-saved.cfg for comparison. Note that each screen uses "xin_".

[xin_1]
file=/home/damo/images/wallpapers/bamboo-bird2.png
mode=5
bgcolor=#001e44

[xin_0]
file=/home/damo/images/wallpapers/bunsen/default/BL-beam-plain.png
mode=5
bgcolor=#001e44

When setting backgrounds, nitrogen should give you options to set the image as Full Screen, Screen 1, Screen 2 etc.
nitrogen.th.png

If you want the same image on 2 monitors then set it as both Screen 1 and Screen 2

PS: For Help with Nitrogen you should be posting in Help & Support, so this thread isn't derailed wink


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

Board footer

Powered by FluxBB