WindowLog.js
[gitlive] / systray-whitelist
1 #!/bin/bash
2
3 #  systray-whitelist
4 #
5 #  This program lets you modify the "systray-whitelist" added in Ubuntu 11.04.
6 #  Programs that implement a "GTK status icon" won't show up in the tray if 
7 #  they are not in the whitelist.
8 #  
9 #  Author:
10 #       Pontus Östlund <pontus@poppa.se>
11
12 #  Copyright (c) 2011 Pontus Östlund
13
14 #  This program is free software: you can redistribute it and/or modify
15 #  it under the terms of the GNU General Public License as published by
16 #  the Free Software Foundation, either version 3 of the License, or
17 #  (at your option) any later version.
18
19 #  This program is distributed in the hope that it will be useful,
20 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
21 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 #  GNU General Public License for more details.
23
24 #  You should have received a copy of the GNU General Public License
25 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
26
27 function add
28 {
29         new=
30         ok=1
31         key=`gsettings get com.canonical.Unity.Panel systray-whitelist`
32
33         for idx in ${key:1:-1};
34         do
35                 idx=${idx:1:-1}
36                 idx=${idx//\'/}
37                 if test "$idx" == "$2";
38                 then
39                         ok=0
40                 else
41                         new="$new'$idx',"
42                 fi
43         done
44
45         if test "$ok" == 1;
46         then
47                 new="[$new'$2']"
48                 `gsettings set com.canonical.Unity.Panel systray-whitelist "$new"`
49                 echo "New whitelist: $new"
50                 echo "You need to logout/login for the change to take effect"
51         else
52                 echo "The program '$2' is already whitelisted"
53         fi
54 }
55
56 function remove
57 {
58         new=
59         ok=0
60         key=`gsettings get com.canonical.Unity.Panel systray-whitelist`
61
62         for idx in ${key:1:-1};
63         do
64                 idx=${idx:1:-1}
65                 idx=${idx//\'/}
66                 if test "$idx" == "$2";
67                 then
68                         ok=1
69                 else
70                         new="$new'$idx',"
71                 fi
72         done
73
74         if test "$ok" == 1;
75         then
76                 new="[${new:0:-1}]"
77                 `gsettings set com.canonical.Unity.Panel systray-whitelist "$new"`
78                 echo "New whitelist: $new"
79                 echo "You need to logout/login for the change to take effect"
80         else
81                 echo "The program '$2' isn't whitelisted"
82         fi
83 }
84
85 function show
86 {
87         echo "Systray whitelist:"
88         key=`gsettings get com.canonical.Unity.Panel systray-whitelist`
89         echo "$key"
90 }
91
92 function show_help
93 {
94         echo "Usage:"
95         echo "  $0 [action] [program]" 
96         echo 
97         echo "[action]:"
98         echo "  add      Adds [program] to whitelist"
99         echo "  remove   Removes [program] from whitelist"
100         echo "  show     Displays the whitelist"
101         echo "  help     Shows this text"
102         echo
103 }
104
105 case $1 in
106 "add")
107         add $@
108         ;;
109
110 "remove")
111         remove $@
112         ;;
113
114 "show")
115         show
116         ;;
117         
118 "help")
119         show_help
120         ;;
121
122 *)
123         show_help
124         ;;
125 esac
126