如何让 Unity 启动器定期改变颜色

如何让 Unity 启动器定期改变颜色

如何让 Unity 启动器随着时间的推移改变颜色?

答案1

简介

下面的脚本循环遍历颜色的十六进制值。它可以在登录时启动,也可以在需要时手动运行

获取脚本

可以直接从本文复制源代码,或者通过 github 按照以下步骤复制:

  1. sudo apt-get install git
  2. cd /opt ; sudo git clone https://github.com/SergKolo/sergrep.git
  3. sudo chmod -R +x sergrep

脚本文件将是/opt/sergrep/unity_launcher_rainbow.sh

要使脚本在每次登录时自动启动,请参阅如何在登录时自动启动应用程序?. 提供/opt/sergrep/unity_launcher_rainbow.sh(完整路径)作为命令

脚本源

#!/usr/bin/env bash
#
###########################################################
# Author: Serg Kolo , contact: [email protected] 
# Date: March 20,2016
# Purpose: Color changer script for Ubuntu Unity launcher
# Written for: 
# Tested on: Ubuntu 14.04
###########################################################
# Copyright: Serg Kolo , 2016
#    
#     Permission to use, copy, modify, and distribute this software is hereby granted
#     without fee, provided that  the copyright notice above and this permission statement
#     appear in all copies.
#
#     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
#     THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#     DEALINGS IN THE SOFTWARE.
ARGV0="$0"
ARGC=$#
main()
{
  renice -n 10 $$ > /dev/null
  num=0;
  while true
  do 
    set_unity_launcher_color   $(printf '%6.6xff' $num)
    num=$(($num+510)) 
    if [ $num -eq 16777215 ]
       then num=0
    fi
    sleep 0.05
    done
}

set_unity_launcher_color()
{
  schema="org.compiz.unityshell" # relocatable schema
  path="/org/compiz/profiles/unity/plugins/unityshell/" #must end with /
  key="background-color"
  hex_string=$1
  gsettings set "$schema":"$path" "$key"  "'#$hex_string'"
}
main

相关内容