Xfce Forum

Sub domains
 

You are not logged in.

#1 2014-06-27 03:17:10

highwind
Member
Registered: 2014-06-07
Posts: 16

[How to] Set a html file as background?

After using wallch, I'm wondering is there a way to set&show an html file as desktop background?


(Using Mint17 + xfce4.10)

Offline

#2 2014-06-27 10:48:05

ToZ
Moderator
From: Toronto, Canada
Registered: 2011-06-02
Posts: 1,335

Re: [How to] Set a html file as background?

Xfce doesn't have this functionality built-in, but I guess you could script something using a 3rd party tool to capture a webpage as an image and then use xfconf-query to set that image as the background. Auto-refresh as required.

However, why not just use wallch? I believe it supports Xfce.

Offline

#3 2014-06-27 12:54:11

highwind
Member
Registered: 2014-06-07
Posts: 16

Re: [How to] Set a html file as background?

Thanks ToZ, wallch seems only support onlinewebsite , what I want is a local HTML
As background.

And how about leave it unsolved?

Last edited by highwind (2014-06-27 13:01:44)


(Using Mint17 + xfce4.10)

Offline

#4 2014-06-27 23:41:44

ToZ
Moderator
From: Toronto, Canada
Registered: 2011-06-02
Posts: 1,335

Re: [How to] Set a html file as background?

highwind wrote:

Thanks ToZ, wallch seems only support onlinewebsite , what I want is a local HTML
As background.

Yep, can't seem to get that to work on wallch. So I decided to through together a quick script that will do this for you:

#!/bin/bash

#Name: 		htmlback
#Description: 	Uses an html file as a desktop background and refreshes on a preset schedule
#		For local files, use file:// prefix
#		For online files, use http:// prefix
#Requires: 	xfdesktop, cutycapt
#Debug mode:	bash -xv /path/to/htmlback 2>&1 | tee htmlback.log

# make sure that only one instance of this script is running per user
lockfile=/tmp/.htmlback.$USER.lockfile
if ( set -o noclobber; echo "locked" > "$lockfile") 2> /dev/null; then
  	trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
  	echo "htmlbackDEBUG: Locking succeeded" >&2

# Set some default vaules

	# refresh time in seconds
  	REFRESH_TIME=60			

  	# location of html file to use as background image		
  	HTML_LOCATION="file:///usr/share/xubuntu-docs/desktop-guide/index.html"
  	#HTML_LOCATION="http://www.thestar.com"

  	# minimal width of image (should match desktop dimension)
  	MIN_WIDTH=1024

  	# minimal height of image (should match desktop dimension)
  	MIN_HEIGHT=768

  	# xfconf wallpaper setting
  	# To get this xfconf entry, in a terminal window, run "xfconf-query -c xfce4-desktop -m" then
  	#	manually change the background. In the terminal window the xfconf wallpaper setting will be displayed
  	XFCONF_WSETTING=/backdrop/screen0/monitorLVDS-0/workspace0/last-image

  	# xfdesktop won't reload an image if it has the same name so we have to toggle the filename back and forth
  	toggle=0
	# loop forever
  	while true; do
  		# get the htmlpage
  		if [ $toggle -eq 0 ]; then
  			cutycapt --url=$HTML_LOCATION --out=/tmp/htmlback0.png --min-width=$MIN_WIDTH --min-height=$MIN_HEIGHT
  		else
  			cutycapt --url=$HTML_LOCATION --out=/tmp/htmlback1.png --min-width=$MIN_WIDTH --min-height=$MIN_HEIGHT
  		fi

  		#sleep for cutycapt to complete (adjust to suit)
  		sleep 10s

  		# set the wallpaper
  		if [ $toggle -eq 0 ]; then
  			xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorLVDS-0/workspace0/last-image -s /tmp/htmlback0.png
  			toggle=1
  		else
  			xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorLVDS-0/workspace0/last-image -s /tmp/htmlback1.png
  			toggle=0
  		fi
  		# change style to "tiled" (looks the best)
		xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorLVDS-0/workspace0/image-style -s 2

		# sleep for the refresh time
		sleep $REFRESH_TIME


	done
	
# can't create lockfile - notify user and quit
else
  	echo "htmlbackDEBUG: Lock failed, check for existing process and/or lock file and delete - exiting." >&2
  	exit 1
fi			

exit 0

Steps:
1. Create the file /usr/local/bin/htmlback with the contents above.

2. Change the default values inside the script to match your needs, specifically:
- REFRESH_TIME -> the time in seconds between a refresh of the background
- HTML_LOCATION -> the location of the html file you want to use. If its a local file, prefix the path with "file://"
- MIN_WIDTH -> the width of your display
- MIN_HEIGHT -> the height of your display
- XFCONF_WSETTING -> information in the script on how to get the actual xfconf entry that points to your screen wallpaper

3. Make the file executable

4. Run the executable in a terminal window for testing.

If you want to ruin automatically at boot, add it to your application startup.

And how about leave it unsolved?

I didn't flag this thread as solved. Only the original author can flag it as solved. Perhaps you inadvertantly selected the option to close the thread?

Last edited by ToZ (2014-06-27 23:44:01)

Offline

#5 2014-06-28 22:57:05

highwind
Member
Registered: 2014-06-07
Posts: 16

Re: [How to] Set a html file as background?

@ToZ , Thank you so much ,I really appreciate your help.

#!/bin/bash

#Name: 		htmlback
#Description: 	Uses an html file as a desktop background and refreshes on a preset schedule
#		For local files, use file:// prefix
#		For online files, use http:// prefix
#Requires: 	xfdesktop, cutycapt
#Debug mode:	bash -xv /path/to/htmlback 2>&1 | tee htmlback.log

# make sure that only one instance of this script is running per user
lockfile=/tmp/.htmlback.$USER.lockfile
if ( set -o noclobber; echo "locked" > "$lockfile") 2> /dev/null; then
  	trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
  	echo "htmlbackDEBUG: Locking succeeded" >&2

# Set some default vaules

	# refresh time in seconds
  	REFRESH_TIME=10			

  	# location of html file to use as background image		
  	HTML_LOCATION="file:///home/path/to/file"
                              #/usr/share/xubuntu-docs/desktop-guide/index.html"
  	#HTML_LOCATION="http://www.thestar.com"

  	# minimal width of image (should match desktop dimension)
  	MIN_WIDTH=800

  	# minimal height of image (should match desktop dimension)
  	MIN_HEIGHT=600

  	# xfconf wallpaper setting
  	# To get this xfconf entry, in a terminal window, run "xfconf-query -c xfce4-desktop -m" then
  	#	manually change the background. In the terminal window the xfconf wallpaper setting will be displayed
  	XFCONF_WSETTING=/backdrop/screen0/monitorVBOX0/workspace0/last-image
                                  #/backdrop/screen0/monitorLVDS-0/workspace0/last-image

  	# xfdesktop won't reload an image if it has the same name so we have to toggle the filename back and forth
  	toggle=0
	# loop forever
  	while true; do
  		# get the htmlpage
  		if [ $toggle -eq 0 ]; then
  			cutycapt --url=$HTML_LOCATION --out=/tmp/htmlback0.png --min-width=$MIN_WIDTH --min-height=$MIN_HEIGHT
  		else
  			cutycapt --url=$HTML_LOCATION --out=/tmp/htmlback1.png --min-width=$MIN_WIDTH --min-height=$MIN_HEIGHT
  		fi

  		#sleep for cutycapt to complete (adjust to suit)
  		sleep 10s

  		# set the wallpaper
  		if [ $toggle -eq 0 ]; then
  			xfconf-query -c xfce4-desktop -p $XFCONF_WSETTING -s /tmp/htmlback0.png
#/backdrop/screen0/monitorLVDS-0/workspace0/last-image 
  			toggle=1
  		else
  			xfconf-query -c xfce4-desktop -p $XFCONF_WSETTING -s /tmp/htmlback1.png
#/backdrop/screen0/monitorLVDS-0/workspace0/last-image 
  			toggle=0
  		fi
  		# change style to "tiled" (looks the best)
#		xfconf-query -c xfce4-desktop -p $XFCONF_WSETTING -s 2   ???
#/backdrop/screen0/monitorLVDS-0/workspace0/image-style 

		# sleep for the refresh time
		sleep $REFRESH_TIME
	done
	
# can't create lockfile - notify user and quit
else
  	echo "htmlbackDEBUG: Lock failed, check for existing process and/or lock file and delete - exiting." >&2
  	exit 1
fi			

exit 0

I made some change to let it work,
However, my original idea is to let the background to be click-able/interactive (html), so I think I will leave this thread as "unsolved".
(ps: I think you are right I may accidentally trigger the solved/unsolved flag, ^_^)


(Using Mint17 + xfce4.10)

Offline

#6 2014-06-29 00:10:52

ToZ
Moderator
From: Toronto, Canada
Registered: 2011-06-02
Posts: 1,335

Re: [How to] Set a html file as background?

highwind wrote:

However, my original idea is to let the background to be click-able/interactive (html)

In that case, why not just run firefox, full screen, pinned and below all other windows? You can use devilspie to automate this. A .ds file like this:

(if
    (is (window_class) "Firefox")
    (begin
       (pin)
       (below)
       (undecorate)
       (maximize)
    )
)

...will do it.

Offline

#7 2014-06-29 02:22:47

highwind
Member
Registered: 2014-06-07
Posts: 16

Re: [How to] Set a html file as background?

@ToZ, Thanks again for introducing such nice tool.

However , as I tested, the following firefox menu will be effected,
I just wondering is that a way I can run the engine but not whole firefox to display my html as background?


(Using Mint17 + xfce4.10)

Offline

#8 2014-06-29 03:34:25

highwind
Member
Registered: 2014-06-07
Posts: 16

Re: [How to] Set a html file as background?

I tried to think about this issue in another way, I install Uzbl to run with devilspie2, looks much better,

smile do you have some other lightweight web-browser recommend?


(Using Mint17 + xfce4.10)

Offline

Board footer

Powered by FluxBB