我正在编写一个脚本,该脚本将使用gnome-tweak-tool系统安装Numix主题。
我想确保如果已经安装了项目,则不要重新安装它们,因此我使用了which [name of item] > /dev/null
。
这是我当前的脚本:
function installNumix() {
echo "Checking if Numix is installed ..."
if ! which gnome-tweak-tool > /dev/null; then
if ! which numix-gtk-theme > /dev/null; then
if ! which numix-icon-theme-circle > /dev/null; then
echo "Installing Numix ..."
sudo add-apt-repository ppa:numix/ppa
sudo apt-get update
sudo apt-get install numix-gtk-theme numix-icon-theme-circle -y
sudo apt-get install gnome-tweak-tool -y
echo "Configuring Numix:"
echo "===================================================================="
echo "Please use the 'tweak-tool' to change your theme to 'Numix'."
echo "[GTK+]: Numix."
echo "[icons]: Numix-Circle."
echo "===================================================================="
gnome-tweak-tool
echo "Numix has been manually configured."
source ~/.profile
changeBackground backgrounds/background.png
changeProfilePicture $(whoami) profile_pictures/profile_picture.png
echo "The Numix has been installed."
sleep 5
fi
fi
else
echo "Numix has already been installed."
sleep 5
fi
}
我的.profile
档案:
#Change desktop background f(x)
#Ex. changeBackground /path/to/image.png
function changeBackground() {
FILE="file://$(readlink -f "$1")"
fileName="${FILE##*/}" # baseName + fileExtension
echo "Changing desktop background to: '$fileName' ..."
dconf write "/org/gnome/desktop/background/picture-uri" "'$FILE'"
echo "Desktop background has been changed."
sleep 5
}
#Change profile picture f(x)
#Ex. changeProfilePicture username /path/to/image.png
function changeProfilePicture() {
FILE="$(readlink -f "$2")"
fileName="${FILE##*/}" # baseName + fileExtension
echo "Checking if 'imagemagick' is installed ..."
if ! command brew ls --versions imagemagick >/dev/null 2>&1; then
echo "Installing 'imagemagick' ..."
brew install imagemagick -y
echo "'Imagemagick' has been installed."
sleep 5
else
echo "'Imagemagick' has already been installed."
sleep 5
fi
echo "Changing profile picture to: '$fileName' ..."
sudo mkdir -p '/var/lib/AccountsService/icons/'"$1"
sudo convert "$2" -set filename:f '/var/lib/AccountsService/icons/'"$1/%t" -resize 96x96 '%[filename:f].png'
echo "Profile picture has been changed."
sleep 5
}
gnome-tweak-tool
您可以使用来在脚本中设置gtk和window-manager主题以及icon-theme,而不是让用户手动使用gsettings
。例如
gsettings set org.gnome.desktop.interface gtk-theme Numix
gsettings set org.gnome.desktop.wm.preferences theme Numix
gsettings set org.gnome.desktop.interface icon-theme Numix-Circle
顺便说一句,除非numix-gtk-theme
和numix-icon-theme-circle
是PATH目录中某个位置的可执行文件,否则which
在它们上运行将无法执行您想要的操作。
而是检查是否存在特定的文件或目录。例如
if [ ! -d /usr/share/themes/Numix ] ; then ... fi
我没有安装Numix主题,所以我不知道这是否是正确的目录-使用dpkg -L numix-gtk-theme
和dpkg -L numix-icon-theme-circle
查找要搜索的正确目录。
或者,不要费心检查软件包是否已安装。赶紧跑:
apt-get -y install numix-gtk-theme numix-icon-theme-circle gnome-tweak-tool
(可选地,将stdout和stderr重定向到/ dev / null)
如果已经安装了这些软件包的最新版本,则apt-get
不会执行任何操作。否则,它将安装或升级它们。
最后,使用,sudo add-apt-repository -y ppa:numix/ppa
这样它就不会提示用户。如果已添加存储库,则不会造成任何危害-它会注释掉/etc/sources.list.d/numix-ubuntu-ppa-yakkety.list
文件中的先前条目,并将ppa添加到文件的开头。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句