14.04 LTS 启动器中的多个铬图标

Stu*_*ent 6 icons unity google-chrome launcher chromium

编辑 2014-04-19:
为我的问题添加一些额外的上下文,这些是我遵循的原始说明http://ricardofeliciano.me/how-to-create-a-unity-launcher-icon-for-each- chromechromium-profile-in-ubuntu/ . 在正式发布日期前几周,我让它与 Ubuntu 14.04 LTS 一起使用。4 月 17 日更新后,我无法再使用它:

原帖:
我在正式发布前几周安装了 Ubuntu 14.04 LTS 并设置了多个谷歌铬配置文件。使用“StartupWMClass”,我设法让每个配置文件在统一启动器中都有一个单独版本的铬图标(相同的图标,在启动器中单独出现)。在 14.04 正式发布后,我更新了所有软件包(包括 Chromium),从那以后我的附加 Chromium 配置文件不再在启动器上获得自己的图标位置,而是与主 Chromium 图标组合在一起。

这是我认为是我的设置的基本要素:

  • ~/.local/share/applications/我下面有我的 *.desktop 文件,其中包含以下几行
    • Exec=chromium-browser --user-data-dir=/home/<mydir>/.config/chromium/Profiles/<profile-name> --class=<profile-class-name> %U
    • StartupWMClass=<profile-class-name>
  • /usr/share/applications/我安装铬时创建了默认的chromium-browser.desktop 文件,其中包含以下行
    • Exec=chromium-browser --class=Chromium-browser %U
    • StartupWMClass=Chromium-browser

添加--class=Chromium-browser到用于执行此技巧的默认安装 .desktop 文件的 Exec= 行,以便每个配置文件(包括默认配置文件)都与启动器上的它们自己的图标相关联。更新后,我不再能够让它工作。

我试过:

  • 关闭所有铬窗,
  • 从启动器解锁任何剩余的铬图标,
  • 使用统一搜索启动默认的 Chromium Web 浏览器,
  • 将出现的图标锁定到启动器
  • 使用统一搜索启动额外的自定义 Chromium 配置文件
  • --> 附加铬配置文件的窗口与为默认铬配置文件启动的图标相关联。他们使用相同的启动器图标。

我尝试重新启动 compiz,注销甚至重新启动我的计算机。

关于我可能缺少什么的任何提示?

ps 让我困惑的一件事是,我为 Google 日历创建的启动器File -> Create application shortcuts...按预期工作(使用它自己的不同图标),甚至没有使用--class=<profile>我认为必要的论点......

rka*_*tos 0

我想出了这个令人厌恶的东西(个人意见......我只是希望它能与 sh 一起工作:))它有一些技巧,但对于两个 Windows 来说非常强大......你也可以指定更多的窗口,但是它们必须通过添加更多内容"specificprofile1"以及相应的功能来手动添加..也许有人可以使其具有更多..逻辑!

#!/bin/bash
# chromium-start.sh $1 
# e.g. put: 
# chrome-start.sh "Profile 1" to .desktop Exec=
# wmctrl -o 1366,0 ; chromium-browser %U --profile-directory=Profile\ 2 & sleep 3; wmctrl -o 0,0

# $1 = Profile folder name

profilename=$1

#2nd Chromium profile
specificprofile1="Profile 1"

echo "starting Chromium"
echo "args: " $1
echo "Profile name: " $profilename
echo "Specific profile: " $specificprofile1

# Just setting Chromium scaling variable, because of course Google Devs don't care about no fractional scaling on linux
scale_var=0.8

# Check if Chromium window with the specified class already exists
# Also allows using icons as "taskbar" switches (clicking icon takes to corresponding Chromium Window)
if wmctrl -l -x | grep "chromium-$profilename"
then
echo "Chromium Window exists, moving focus to it"
wmctrl -x -R chromium-"$profilename"
echo "true"

# Check if 2nd profile $specifiedprofile1 has been started yet or not. The WMCLASS(es) has to have been set correctly...
elif [[ "$specificprofile1" == "$profilename" ]] && [[ ! "`wmctrl -l -x | grep chromium-"$specificprofile1"`" ]]
then
    # TODO: Nesting
    if [ "$specificprofile1" == "$profilename" ]
    then
    echo $specificprofile1 "equals" $profilename
    fi
echo "#2 Chromium Window for $specificprofile1 does not exist"
# wmctrl moves to specific position of desktop (1366 means moving to the following workspace since my resolution is 1366x768)
# Be careful if using sleep timing, since the command needs to have enough time to execute to have the window in the correct workspace
wmctrl -o 1366,0
chromium-browser  --profile-directory="$profilename" --force-device-scale-factor=$scale_var %U &
# https://askubuntu.com/a/626524/654028
# Set's the chromium window which was opened latest to have a custom class, since Chromium doesn't care about the --class= flag...
# It has it's limitations, but should be robust enough for most use... Has not been tested long term.. Something probably could reset the WM_CLASS again
# xprop -id "$(wmctrl -l -x| grep "chromium-browser" | tail -n 1 |awk '{ print $1 }')" -f WM_CLASS 8s -set WM_CLASS "chromium-browser.chromium-$specificprofile1"

# Alternative method for checking if a window with specified class exists
# xprop -id "$(wmctrl -l -x| grep "chromium-$profilename" | tail -n 1 |awk '{ print $1 }')" | grep -o "WM_CLASS(STRING) = ".*"" | grep -o '".*"' | tr -d '"'

# /sf/answers/1360896631/
winrep=""
while [[ ! "`echo $winrep | grep -l "Map State: IsViewable"`" ]]
do
    winid="$(wmctrl -l -x| grep "chromium-$profilename" | tail -n 1 |awk '{ print $1 }')"
    # print $winid
    winrep="$(xwininfo -id $winid | grep -o 'Map State: IsViewable')"
    # print $winrep
    sleep 0.75
    xprop -id "$(wmctrl -l -x| grep "chromium-browser" | tail -n 1 |awk '{ print $1 }')" -f WM_CLASS 8s -set WM_CLASS "chromium-browser.chromium-$specificprofile1"
done
# sleep 3

# Move Window directly to workspace (#2 with 1366x768 resolution x = 1366), optionally comment out wmctrl -o 1366,0
# wmctrl -v -i -r $winid -e 0,1366,0,-1,-1

# sleep 5
# Move back to workspace #1
wmctrl -o 0,0


elif ! wmctrl -l -x | grep chromium-"$profilename"
then
echo "#3 Chromium Window $profilename does not exist"
wmctrl -o 0,0
chromium-browser  --profile-directory="$profilename" --force-device-scale-factor=$scale_var %U &


# https://askubuntu.com/a/626524/654028
# ....
# sleep 3

winrep=""
while [[ ! "`echo $winrep | grep -l "Map State: IsViewable"`" ]]
do
    winid="$(wmctrl -l -x| grep "chromium-$profilename" | tail -n 1 |awk '{ print $1 }')"
    # print $winid
    winrep="$(xwininfo -id $winid | grep -o 'Map State: IsViewable')"
    # print $winrep
    sleep 0.75
    xprop -id "$(wmctrl -l -x| grep "chromium-browser" | tail -n 1 |awk '{ print $1 }')" -f WM_CLASS 8s -set WM_CLASS "chromium-browser.chromium-$profilename"
done
wmctrl -o 0,0
# xprop -id "$(wmctrl -l -x| grep "chromium-browser" | tail -n 1 |awk '{ print $1 }')" -f WM_CLASS 8s -set WM_CLASS "chromium-browser.chromium-$profilename"
fi
Run Code Online (Sandbox Code Playgroud)

问题:

打印给出错误(弃用警告..):

Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/%{ <-- HERE (.*?)}/ at /usr/bin/print line 528.
Run Code Online (Sandbox Code Playgroud)

为了调试,您可以使用以下命令打印使用实际图标时的错误: https://askubuntu.com/a/664272/654028(# 手动替代方案)

awk '/^Exec=/ {sub("^Exec=", ""); gsub(" ?%[cDdFfikmNnUuv]", ""); exit system($0)}' chrome-ws2.desktop
Run Code Online (Sandbox Code Playgroud)

while 循环出错,可能是因为循环间隔

Error: no such file "at while function"
xwininfo: error: -id requires argument
xprop: error: Invalid window id format: .
xwininfo: error: -id requires argument
xprop: error: Invalid window id format: .
xwininfo: error: -id requires argument
xprop: error: Invalid window id format: .
Run Code Online (Sandbox Code Playgroud)

此外,当单击相应的 .desktop 图标太快时(在设置自定义类之前?),将打开一个新窗口。

(相当)有时,当从两个 Chromium 启动太快(~<3s)时,之前打开的窗口的类会重置为 chromium-browser.chromium-browser.. 然后你可以预期图标会交换或其他意外行为。