我正在尝试编写一个 bash 脚本,用于在工作区之间切换,并在切换过程中显示一些对话框提示。我正在运行带有 Budgie remix 的 Ubuntu 17.04。
单独使用wmctrl
或时zenity
,它们都可以正常工作。但是将它们放在一起时,budgie 窗口管理器会因分段错误而崩溃。
这在使用wmctrl -s 0
和时都会发生xdotool set_desktop 0
。它们单独使用时效果很好,但与结合使用时则不行zenity
。
这是我的代码(引起分段错误)
#!/bin/bash
desktop=$(xdotool get_desktop) #Get current workspace id
if [ "${desktop}" -eq 0 ] #If workspace == 0
then
wmctrl -s 3 #Switch to workspace 3
firefox --new-window "http://www.reddit.com"
else
zenity --question --title "Switch Workspace?" --text "Are you sure you wish to return to previous workspace?"
if ! $? #If response Yes
then
wmctrl -s 0 #Switch back
else
notify-send "Operation Aborted" "User canceled workspace return."
fi
fi
wmctrl
单独使用命令时的工作代码示例
#!/bin/bash
desktop=$(xdotool get_desktop) #Get current workspace id
if [ "${desktop}" -eq 0 ] #If workspace == 0
then
wmctrl -s 3 #Switch to workspace 3
firefox --new-window "http://www.reddit.com"
else
wmctrl -s 0 #Switch back
fi
zenity
单独使用命令时的工作代码示例
#!/bin/bash
desktop=$(xdotool get_desktop) #Get current workspace id
if [ "${desktop}" -eq 0 ] #If workspace == 0
then
wmctrl -s 3 #Switch to workspace 3
firefox --new-window "http://www.reddit.com"
else
zenity --question --title "Switch Workspace?" --text "Are you sure you wish to return to previous workspace?"
if ! $? #If response Yes
then
notify-send "Switch Workspace" "Operation placeholder."
else
notify-send "Operation Aborted" "User canceled workspace return."
fi
fi
以下是我发现的journalctl
Dec 02 11:17:54 main budgie-wm.desktop[20079]: Window manager warning: Received a NET_CURRENT_DESKTOP message from a broken (outdated) client who sent a 0 timestamp
Dec 02 11:17:54 main kernel: budgie-wm[20079]: segfault at 18 ip 00007fa255e8dfc1 sp 00007fff13189710 error 4 in libmutter-0.so.0.0.0[7fa255df0000+131000]
Dec 02 11:17:55 main gnome-session-binary[19810]: WARNING: Application 'budgie-wm.desktop' killed by signal 11
Dec 02 11:17:55 main gnome-session[19810]: gnome-session-binary[19810]: WARNING: Application 'budgie-wm.desktop' killed by signal 11
Dec 02 11:17:55 main ckb.desktop[20137]: QXcbConnection: XCB error: 148 (Unknown), sequence: 423, resource id: 0, major code: 140 (Unknown), minor code: 20
Dec 02 11:17:56 main budgie-wm[21537]: invalid (NULL) pointer instance
Dec 02 11:17:56 main budgie-wm[21537]: g_signal_connect_object: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
zenity
当用于触发工作区切换但两个组件各自都能正常工作时,是什么导致了分段错误?
答案1
归类为 Zenity 中的错误,请参阅:https://bugs.launchpad.net/ubuntu/+source/zenity/+bug/1735917