You are not logged in.

#1 2012-02-08 17:18:03

pw_f100_220
Member
From: about
Registered: 2009-12-03
Posts: 107

Nitrogen wallpaper switcher: Dual Screen wallpaper via bash?

I've grown quite attached to a little script for my laptop that lets me randomly switch the background with nitrogen:

#! /bin/bash
WALLPAPERS="/home/elias/Pics/BackgroundShow"
ALIST=( `ls -w1 $WALLPAPERS` )
RANGE=${#ALIST[@]}
let "number = $RANDOM"
let LASTNUM="`cat $WALLPAPERS/.last` + $number"
let "number = $LASTNUM % $RANGE"
echo $number > $WALLPAPERS/.last
nitrogen --set-zoom-fill --save $WALLPAPERS/${ALIST[$number]}           <---------- Just need to specify the screen here...

I've had no luck finding how to change just screen 1 or 2 without the GUI.  If there's a way, I would just have a separate hotkey for both.  man nitrogen and nitrogen --help say nothing about setting for a particular screen. 

Any help would be appreciated


Sometimes I just want people to expect me to do what I would do instead of what most people would do.

Offline

#2 2012-02-08 17:23:52

desm0tes
Member
From: 127.0.0.1
Registered: 2012-02-04
Posts: 233
Website

Re: Nitrogen wallpaper switcher: Dual Screen wallpaper via bash?

What about

DISPLAY=":0.1"

Offline

#3 2012-02-08 17:32:03

Gusar
Member
Registered: 2009-08-25
Posts: 3,607

Re: Nitrogen wallpaper switcher: Dual Screen wallpaper via bash?

desm0tes wrote:

What about

DISPLAY=":0.1"

There's no separate DISPLAYs anymore in the xrandr world.

@pw_f100_220: May I suggest using imlibsetroot instead of nitrogen? It can change just a single screen using "-x 0" and "-x 1". The rest of it's options shouldn't be hard to figure out, just look at the --help output.

Offline

#4 2012-02-11 02:43:51

pw_f100_220
Member
From: about
Registered: 2009-12-03
Posts: 107

Re: Nitrogen wallpaper switcher: Dual Screen wallpaper via bash?

I'm playing with imlibsetroot, but it doesn't appear to have the same "zoom-fill" function, and if you set one at a time, it clears the other screen.  So you can shuffle both with this:

#! /bin/bash
WALLPAPERS="/home/elias/Pics/BackShow"
ALIST=( `ls -w1 $WALLPAPERS` )
RANGE=${#ALIST[@]}
let "number = $RANDOM"
let LASTNUM="`cat $WALLPAPERS/.last` + $number"
let "number = $LASTNUM % $RANGE"
echo $number > $WALLPAPERS/.last
let "number2 = $RANDOM"
let LASTNUM="`cat $WALLPAPERS/.last` + $number2"
let "number2 = $LASTNUM % $RANGE"
echo $number2 > $WALLPAPERS/.last
imlibsetroot -x 0 -s $WALLPAPERS/${ALIST[$number]} -x 1 -s $WALLPAPERS/${ALIST[$number2]}

the option -s scales the image until it fills either the x or y dimension leaving black space.  Of course I could crop or limit myself to images with the right aspect ratio, but that's not a solution.  The options seem fairly extensive, but I don't see a way to emulate "zoom-fill":

usage: imlibsetroot [globalopts] {[screenopts] [imageopts] <filename>}+

global options
        --help          print usage information
        --version       print version information
        --composite     combine the images with the current root window
        --display DDD   connect to X display DDD
        --store         store the new root image to ~/.background.png
        --store FILE    store the new root image to FILE
        --storeslices   store the root image of each xinerama display
                          as a seperate file.  (Implies --store .)

screen options
        -x s            operate on the single virtual xinerama screen
                          (default)
        -x e            operate on all xinerama screens independently
        -x N            operate on xinerama screen N

image options
        -s              scale pixmap to the current screen's size
                          preserving the pixmap's original aspect ratio
        -s a            scale pixmap to the current screen's size
                          preserving the pixmap's original aspect ratio
        -s f            scale pixmap to the current screen's size
                          without regard to the pixmap's original
                          aspect ratio
        -s N            scale pixmap by N percent
        -s X,Y          set the pixmap's width to X pixels and height
                          to Y pixels
        -m {xy}         mirror across the X/Y axis
        -r {r|rr|l|ll}  rotate right/left once or twice
        -f {xy}         flip the pixmap across the X/Y axis
        -p c            center pixmap on both axes
        -p cx           center pixmap on x
        -p cy           center pixmap on y
        -p X,Y          place pixmap at position X, Y on the current
                          screen (current screen based coordinates)
        -t              (integer tiling if combined with center
        --bg COLOR      set background color (the area not covered by the
                          image) to COLOR (COLOR may be a mnemonic, or a
                          RRR,GGG,BBB triple)  (may be used without an image)
        --bgcolor COLOR same as --bg

Sometimes I just want people to expect me to do what I would do instead of what most people would do.

Offline

#5 2012-02-11 03:00:27

pw_f100_220
Member
From: about
Registered: 2009-12-03
Posts: 107

Re: Nitrogen wallpaper switcher: Dual Screen wallpaper via bash?

So just for fun, I tried --display as an option (which is not listed anywhere) with various titles: xin_0, 0, 0.0, 1, 0.1, etc.  And it returns:

(nitrogen:8108): Gtk-WARNING **: cannot open display: 0.0

Is this nitrogen telling me it's the wrong display or GTK telling me I'm trying to run nitrogen on the wrong display?  In other words, if I could find out what nitrogen wants to call the displays, would --display work?  If you try other forms (--DISPLAY...) it returns "Unexpected argument DISPLAY" which suggests that --display is real...or am I just reaching through the dark?

I looked at nitrogens bg-saved.cfg file, and they were calling the displays [xin_0] and [xin_1].


Sometimes I just want people to expect me to do what I would do instead of what most people would do.

Offline

#6 2013-07-29 11:33:31

Tasulian
Member
Registered: 2013-07-29
Posts: 1

Re: Nitrogen wallpaper switcher: Dual Screen wallpaper via bash?

So I know this is old and I'm not sure if you still care, but I managed to make a bit of a workaround. I modified the script you listed to change the bg-saved.cfg file and give nitrogen the restore command.

#! /bin/bash
#using the path WALLPAPERS will select a new random wallpaper
WALLPAPERS="/file/path/to/wallpapers"
ALIST=( `ls -w1 $WALLPAPERS` )
RANGE=${#ALIST[@]}
let "number = $RANDOM"
let LASTNUM="`cat $WALLPAPERS/.last` + $number"
let "number = $LASTNUM % $RANGE"
echo $number > $WALLPAPERS/.last 
sed -i '7 c\file='$WALLPAPERS/${ALIST[$number]}'' /home/user/.config/nitrogen/bg-saved.cfg
let "number = $RANDOM"
let LASTNUM="`cat $WALLPAPERS/.last` + $number"
let "number = $LASTNUM % $RANGE"
echo $number > $WALLPAPERS/.last 
sed -i '12 c\file='$WALLPAPERS/${ALIST[$number]}'' /home/user/.config/nitrogen/bg-saved.cfg
nitrogen --restore
exit

I'm definitely a Linux newbie, so there me a more elegant way to achieve this. Using this, you should be able write a cron job or have conky execute it to change wallpapers on a schedule.

Offline

#7 2014-12-04 16:38:53

rouadec
Member
Registered: 2013-08-19
Posts: 5

Re: Nitrogen wallpaper switcher: Dual Screen wallpaper via bash?

I've adapted your script to :

#!/bin/bash
#using the path WALLPAPERS will select a new random wallpaper
WALLPAPERS=~/data/images/wallpapers
RANGE=$(ls $WALLPAPERS | wc -l)

for i in 2 7 12 ; do
  let "number = $RANDOM % $RANGE"
  IMAGE=$(ls $WALLPAPERS | head -$number | tail -1)
  sed -i $i' c\file='"$WALLPAPERS/$IMAGE"'' ~/.config/nitrogen/bg-saved.cfg
done

nitrogen --restore

Offline

Board footer

Powered by FluxBB