gnome - 如何在 GNOME2/metacity 中自动打开所有工作区的窗口?

标签 gnome window-managers metacity

假设我想在一个工作区中运行

sleep 10 && zenity --warning --text 'Wake up!'

然后我在不同的工作空间中处理其他事情。如何在我所在的工作区而不是我输入命令的原始工作区中弹出此 zenity 窗口?或者让它在所有工作区中弹出更容易吗?

最佳答案

我还没有找到一种优雅的方法来在所有工作区中同时弹出这样的对话框(多路复用),但经过一番摆弄之后发现 wmctrl 可以让您设置窗口位置、大小和(最重要的是)让它在当前事件的工作区上提升它。

在我的具体情况下,我需要它也适用于通过 cronat 安排的通知,这需要稍微不同的方法,如以下 shellscript 所示:

#!/usr/bin/env bash
## demo of how to raise a zenity-notification on the active workspace
## license: MIT  copyright: antiplex

export DISPLAY=:0.0

## start wmctrl with a delay in subshell
(sleep 1; wmctrl -r TimedWarning -e 0,40,30,-1,-1; wmctrl -R TimedWarning) &

## launch a zenity dialogue of your choice
zenity --warning --title="TimedWarning" --text="Time is up!" --display=:0.0

出于某种奇怪的原因,当使用 at 进行调度并且终端仍然打开时,上面的脚本还会将我安排执行的终端窗口拉到事件工作区。

这是使用通知守护进程/libnotify 的另一个变体(在基于 debian 的系统上检查包 libnotify-bin),它也不会在事件工作区上启动终端:

#!/usr/bin/env bash
## demo of how to raise a non-volatile libnotify-notification 
## on the currently active workspace
## license: MIT  copyright: antiplex

export DISPLAY=:0.0

## critical notifications with expire time 0 need to be manually confirmed
notify-send --expire-time 0 -u critical TimedWarning "Time is up!"

## rename window title as notify-send would name all its windows 'notify-send'
wmctrl -r notify-send -T TimedWarning

## set new position in upper left corner, keeping the windows size
wmctrl -r TimedWarning -e "0,40,30,-1,-1"

## raise window on currently active workspace
wmctrl -R TimedWarning 

关于gnome - 如何在 GNOME2/metacity 中自动打开所有工作区的窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18880524/

相关文章:

javascript - GNOME 中鼠标进入屏幕特定像素范围时的激活方法

cmake - 在 cmake 中使用 intltool

gnome - 如何在Gnome Shell扩展中为St.Icon设置PNG文件

Android:如何将 View 添加到 WindowManager,并使其始终 float 在我的应用程序顶部?

java - 如何使用 Java 在屏幕上移动 Windows 窗口?

opengl - 最小化全屏 Xlib OpenGL 窗口

root - 如何找到排除任何 GNOME 面板或其他 GNOME "things"的根窗口的 X 几何图形?

c - 在 Gnome/metacity 中,我们可以将一个键绑定(bind)到需要用户从键盘输入的命令吗?