請問如何讓ubuntu的桌面變成會定時更換桌布... [論壇 - Ubuntu基本設定]
正在瀏覽:
1 名遊客
訪客
|
請問如何讓ubuntu的桌面變成會定時更換桌布... |
|
---|---|---|
Anon:訪客
|
請問諸位先進,
如何將ubuntu的桌面設成像KDE下,可以指定一個 資料夾目錄裡的圖片,然後定時更換成桌布呢? 我找了ubuntu裡的套件管理程式,也找不到相關的套件… (soucelist是 http://us.archive.ubuntu.com/ubuntu) 感謝回覆~
2005/6/10 11:21
| fd937 51649 ac3ea 8f877
|
|
![]() |
訪客
|
Re: 請問如何讓ubuntu的桌面變成會定時更換桌布... |
|
---|---|---|
Anon:訪客
|
請安裝 chbg,hoary 裡面有
2005/6/10 11:27
| c0ba1 7c23a 26ff8 c3144
|
|
![]() |
訪客
|
Re: 請問如何讓ubuntu的桌面變成會定時更換桌布... |
|
---|---|---|
Anon:訪客
|
感恩回覆~
可是我用 root登入執行 chbg,在對話框裡 選了圖片的資料夾後,點選「Action」->「Run」 後,背景卻沒有反應,在終端機出現如下訊息: Gtk-WARNING **: invalid cast from (NULL) pointer to `GtkLabel' Gtk-CRITICAL **: file gtklabel.c: line 260 (gtk_label_set_text): assertion `GTK_IS_LABEL (label)' failed. 請問該如何解呢? 感恩~
2005/6/10 22:21
| 6c1e6 71f9a f5b46 d9c1a
|
|
![]() |
訪客
|
Re: 請問如何讓ubuntu的桌面變成會定時更換桌布... |
|
---|---|---|
Anon:訪客
|
由於上述問題無法解決,所以我用google找到了一個可以更換桌布的shell如下:
(http://mysite.mweb.co.za/residents/clasqm/ubuntu.html) ************************************************************ #!/bin/sh #Name: ranwp.sh #Function: Wallpaper randomiser #Adapted for Ubuntu Warty from suggestions #found on http://gnome-hacks.jodrell.net/ #License: Public Domain #Instructions: Place this script in a /bin directory #and do a chmod +x #Then put it in a crontab or with your startup programs. #Or both. Ubuntu Warty doesn't have a crontab editor, #but you can install gcrontab via synaptic. cd /mnt/win_d2/彩色圖庫 #Change this location if you keep your backgrounds elsewhere. #Just one location allowed, sorry. #Oh yes, it would be helpful if your backgrounds did not have #spaces in their filenames! If the script encounters such #a filename, it generates an error and throws up a blank screen. #Just go through the list and replace any spaces in the #names with "_" or "-" IMGS=`find . -iname '*.jpg' -o -iname '*.png' -o -iname '*.tif'` #You may want to get rid of the tiger head in #/usr/share/backgrounds/scalable, in fact, blow #that directory away! N=`echo $IMGS | wc -w` #Find out how many pictures we got ((N=RANDOM%N)) #Take a random number between 1 and N BGNAME=`echo $IMGS | cut -d '/' -f $N | cut -d ' ' -f 1` #We have to cut twice to get rid of an irritating " ." at the #end after the first cut # start of gconftool command - all on one line! gconftool-2 -t str --set /desktop/gnome/background/picture_filename "/usr/share/ backgrounds/$BGNAME" # end of gconftool command # start of gconftool command - all on one line! gconftool-2 -t str --set /desktop/gnome/background/picture_options "stretched" #Possible values are "none", "wallpaper" (eg tiled), "centered", "scaled", "stre tched" # end of gconftool command #That's it, your background should have changed. ************************************************************ 我把目錄指定到 /mnt/win_d2/彩色圖庫 ,檔案類型增加tif檔, 用終端機跑了script後,背景卻只是由預設的圖案變黑耶… 請問是否有哪邊沒有設定好呢? 謝謝~
2005/6/11 11:22
| 3d5bd f107d e596c e77e8
|
|
![]() |
訪客
|
Re: 請問如何讓ubuntu的桌面變成會定時更換桌布... |
|
---|---|---|
Anon:訪客
|
Hi,不好意思我沒看你的 script(因為有點長..)
不過我用 python 寫看看,試了一下應該沒問題 不知道你要不要用看看? #!/usr/bin/env python # -*- coding: UTF-8 -*- import glob import random import os # 設定存放圖檔的路徑 path = '/usr/share/backgrounds/' # 使用此路徑底下 *.png 來用 files = glob.glob(os.path.join(path,'*.png')) files.extend(glob.glob(os.path.join(path,'*.jpg'))) files.extend(glob.glob(os.path.join(path,'*.tif'))) # 從 files 裡面隨機選一張 picture = files[random.randrange(len(files))] # 使用 gconftool-2 設定為桌面 os.system("gconftool-2 -t str --set /desktop/gnome/background/picture_filename %s"%picture)
2005/6/14 1:57
| 3d5bd f107d e596c e77e8
|
|
![]() |
Re: 請問如何讓ubuntu的桌面變成會定時更換桌布... |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員一級
![]() ![]() 註冊日期:
2005/6/13 12:22 所屬群組:
已註冊使用者 等級: 1
HP : 0 / 21
![]() |
sorry, 剛剛忘記按登入..
另外問一下 xoops 沒支援彩色語法嗎? 例如 [code python]...[/code]
2005/6/14 2:01
|
||||||||||
![]() |
訪客
|
Re: 請問如何讓ubuntu的桌面變成會定時更換桌布... |
|
---|---|---|
Anon:訪客
|
感恩您,可是我發現我的電腦跑起來有問題…
1.我的ubuntu安裝完後,沒有/desktop/gnome/background/ 這個目錄耶? 2.我直接用 sh xxx 跑了您提供的 python程式碼後,出現如下錯 誤訊息: ch: line 3: import: command not found ch: line 4: import: command not found ch: line 5: import: command not found ch: line 8: path: command not found ch: line 10: syntax error near unexpected token `(' ch: line 10: `files = glob.glob(os.path.join(path,'*.png'))' 不知道是不是我還需要裝什麼套件? 我的python是ubuntu的預設安裝2.4版。 謝謝您~
2005/6/14 18:21
| 3d5bd f107d e596c e77e8
|
|
![]() |
Re: 請問如何讓ubuntu的桌面變成會定時更換桌布... |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員一級
![]() ![]() 註冊日期:
2005/6/13 12:22 所屬群組:
已註冊使用者 等級: 1
HP : 0 / 21
![]() |
gconf 設定桌布的路徑是指
~/.gconf/desktop/gnome/background/ 然後去改裡面 xml 檔的設定值, 所以你要有的目錄是 /usr/share/backgrounds/ 當然你也可以自己改成你放圖片的絕對路徑. 就是把 path = '/usr/share/backgrounds/' 把這行改成你放圖片的地方 那個 script ,例如你把他存成 wallpaper.py 之後 chmod +x wallpaper.py 然後放到 crontab 去定時跑, 他就會定時更換桌布了; 如果你要直接執行,不是用 sh wallpaper.py 因為他不是 shell script, 你可以直接 ./wallpaper.py 或 python wallpaper.py 看看桌面有沒有改變. 希望有點幫助 ![]()
2005/6/14 20:45
|
||||||||||
![]() |
訪客
|
Re: 請問如何讓ubuntu的桌面變成會定時更換桌布... |
|
---|---|---|
Anon:訪客
|
謝謝您,可以了 ^_^
感恩您耐心的回覆~
2005/6/14 22:24
| 3d5bd f107d e596c e77e8
|
|
![]() |
Alan
|
Re: 請問如何讓ubuntu的桌面變成會定時更換桌布... |
|
---|---|---|
Anon:Alan
|
請問
我依照以上方式操作後 並沒有顯示錯誤訊息 但是.............. 桌布也是不會改變 我的圖片是放在以下的目錄 /media/sda6/media/Picture/Wallpaper-W/1440x900/ 於是我改寫成 # 設定存放圖檔的路徑 path = '/media/sda6/media/Picture/Wallpaper-W/1440x900/' 這樣對嗎 可是就是不會換桌布阿 想麻煩前輩 是哪裡出問題 謝謝
2007/11/22 21:47
| 2e8cd 49e65 8a8e9 36188
|
|
![]() |
您可以查看帖子.
您不可發帖.
您不可回覆.
您不可編輯自己的帖子.
您不可刪除自己的帖子.
您不可發起投票調查.
您不可在投票調查中投票.
您不可上傳附件.
您不可不經審核直接發帖.