我非常喜欢引言,想将其作为壁纸显示在我的桌面上。
在纯色图像的中间打印引文作为桌面壁纸。
有没有什么软件可以做这个工作?我知道有很多软件可以将随机图像显示为壁纸,但是这个软件可以生成带有文本的图像并将其显示为壁纸。
答案1
您可以编写一个 bash 脚本来为您执行此操作。基于xplanet 教程(对于设置壁纸,这是一些 gconf-magic ;))和此主题使用 imagemagick 编写文本。
像这样:
#!/bin/bash
convert -font "./verdana.ttf" -fill "#101411" -pointsize 33 -gravity "West" -draw "text 1,0 'foobar'" bg.png text.png
gconftool -t str -s /desktop/gnome/background/picture_filename text.png
现在我们开始吧,一个功能齐全的‘创建一个带有随机引语的壁纸’,它甚至可以修改为‘选择一个随机壁纸来在其上打印一个随机引语’。;)
使用方法:只需查看会议部分。玩得开心!
#!/bin/bash
# This is a script which prints random quotes (gathered from files) on to
# a defined wallpaper.
# Some ideas are coming from the xplanet-script located at: http://rbrusu.com/xplanet-desktop-wallpape.html
# Written by Robert 'Bobby' Zenz ([email protected])
# Written for UK at Superuser.com
# Config-Section
# --------------
quote=~/quotes.txt # Set this to a folder, for picking random files, or set
# set it to a file, to pick random lines
wallpaper=~/wallpapers/ # Set it to a fixed wallpaper, or to a folder to pick
# a random one inside that
tempPic=tempWall.png # The name of the temporary file
textSize=33 # The size of the text
textColor="#555555" # The color of the text (watch the quotation marks!)
sleep=3m # Set how long the script will pause before
# picking a new wallpaper/quote
#---------------
# Global variable, please ignore this...
pickedFile=GlobalyDefined
pickedQuote=GlobalyDefined
pickedWallpaper=GlobalyDefined
function getRandomLine {
pickedQuote=$(shuf -n 1 $1)
}
function getRandomFile {
cd $1
set -- *
length=$#
random_num=$(( $RANDOM % ($length + 1) ))
pickedFile=${!random_num}
while [ ! -e $pickedFile ]; do
pickedFile=${!random_num}
done
pickedFile=$(pwd)/$pickedFile
cd -
}
function main {
if [ -d $quote ]; then
getRandomFile $quote
pickedQuote=$(cat $pickedFile)
fi
if [ -f $quote ]; then
getRandomLine $quote
fi
if [ -d $wallpaper ]; then
getRandomFile $wallpaper
pickedWallpaper=$pickedFile
fi
if [ -f $wallpaper ]; then
pickedWallpaper=$wallpaper
fi
convert -fill "$textColor" -pointsize $textSize -gravity "Center" -draw "text 1,0 '$pickedQuote'" $pickedWallpaper $tempPic
gconftool -t str -s /desktop/gnome/background/picture_filename $tempPic
sleep $sleep
exec $0
}
main
现在那个脚本在 GitHub 上有家。