Пример #1
0
func (rs RunningSource) GetMatches(inp string, ct *CommandTray) []Command {
	cmds := make([]Command, 0)

	if ct.X == nil {
		return []Command{}
	}

	clis, err := ewmh.ClientListGet(ct.X)

	if err != nil {
		return cmds
	}

	for _, xwin := range clis {
		dt, err := ewmh.CurrentDesktopGet(ct.X)

		if err != nil {
			dt = 0xFFFFFFFF
		}

		wdt, err := ewmh.WmDesktopGet(ct.X, xwin)
		if err != nil {
			wdt = dt
		}

		if dt != wdt {
			continue
		}

		name, err := xprop.PropValStr(xprop.GetProperty(ct.X, xwin, "_NET_WM_NAME"))
		if err != nil {
			//print("Err1: ", err.Error(), "\n")
			name, err = xprop.PropValStr(xprop.GetProperty(ct.X, xwin, "WM_NAME"))
			if err != nil {
				//print("Err2: ", err.Error(), "\n")
				name = "Unnamed Window"
			}
		}

		if strings.Contains(strings.ToLower(name), inp) {
			cmds = append(cmds, RunningCommand{X: ct.X, win: xwin, name: name})
		}
	}

	return cmds
}
Пример #2
0
func (app *RuntimeApp) updateWmName(xid xproto.Window) {
	if name, err := ewmh.WmNameGet(XU, xid); err == nil && name != "" {
		app.xids[xid].Title = name
		return
	}

	if name, err := xprop.PropValStr(xprop.GetProperty(XU, xid,
		"WM_NAME")); err == nil {
		app.xids[xid].Title = name
	}
}
Пример #3
0
func (ams *AppMenuSource) Open(ct *CommandTray) bool {
	ams.app = nil
	ams.menu = nil

	active, err := ewmh.ActiveWindowGet(ct.X)
	if err != nil {
		return false
	}

	uniqName, err := xprop.PropValStr(xprop.GetProperty(ct.X, active, "_GTK_UNIQUE_BUS_NAME"))
	if err != nil {
		return false
	}

	pathMenu, err := xprop.PropValStr(xprop.GetProperty(ct.X, active, "_GTK_APP_MENU_OBJECT_PATH"))
	if err != nil {
		return false
	}

	pathApp, err := xprop.PropValStr(xprop.GetProperty(ct.X, active, "_GTK_APPLICATION_OBJECT_PATH"))
	if err != nil {
		return false
	}

	// Done parsing props! Yay!

	ams.app = &utils.GtkActions{
		ams.Conn.Object(uniqName, dbus.ObjectPath(pathApp)),
	}

	ams.menu = &utils.GtkMenu{
		ams.Conn.Object(uniqName, dbus.ObjectPath(pathMenu)),
	}

	return true
}
Пример #4
0
func (icon *Icon) Class() string {
	if icon.classCache != "" {
		return icon.classCache
	}

	val, err := xprop.PropValStr(xprop.GetProperty(icon.Socket.X, icon.Socket.Id, "WM_CLASS"))

	if err != nil {
		println("Error getting property:", err)
		return ""
	}

	icon.classCache = val

	return val
}
Пример #5
0
func (cmd TagGet) Run() gribble.Value {
	if !validTagName.MatchString(cmd.Name) {
		return cmdError("Tag names must match %s.", validTagName.String())
	}

	tval := ""
	withClient(cmd.Client, func(c *xclient.Client) {
		var err error

		tagName := fmt.Sprintf("_WINGO_TAG_%s", cmd.Name)
		tval, err = xprop.PropValStr(xprop.GetProperty(wm.X, c.Id(), tagName))
		if err != nil {
			// Log the error, but give the caller an empty string.
			logger.Warning.Println(err)
		}
	})
	return tval
}
Пример #6
0
func (cmd TagGet) Run() gribble.Value {
	if !validTagName.MatchString(cmd.Name) {
		return cmdError("Tag names must match %s.", validTagName.String())
	}

	var cid xproto.Window
	tagName := fmt.Sprintf("_WINGO_TAG_%s", cmd.Name)
	if n, ok := cmd.Client.(int); ok && n == 0 {
		cid = wm.Root.Id
	} else {
		withClient(cmd.Client, func(c *xclient.Client) {
			cid = c.Id()
		})
	}
	tval, err := xprop.PropValStr(xprop.GetProperty(wm.X, cid, tagName))
	if err != nil {
		// Log the error, but give the caller an empty string.
		logger.Warning.Println(err)
		return ""
	}
	return tval
}
Пример #7
0
func find_app_id_by_xid(xid xproto.Window, displayMode DisplayModeType) string {
	var appId string
	if displayMode == DisplayModeModernMode {
		if id, err := xprop.PropValStr(xprop.GetProperty(XU, xid, "_DDE_DOCK_APP_ID")); err == nil {
			appId = getAppIDFromDesktopID(normalizeAppID(id))
			logger.Debug("get app id from _DDE_DOCK_APP_ID", appId)
			return appId
		}
	}
	wmClass, _ := icccm.WmClassGet(XU, xid)
	var wmInstance, wmClassName string
	if wmClass != nil {
		wmInstance = wmClass.Instance
		wmClassName = wmClass.Class
	}
	name, _ := ewmh.WmNameGet(XU, xid)
	pid, err := ewmh.WmPidGet(XU, xid)
	if err != nil {
		logger.Info("get pid failed, ", name)
		if name != "" {
			pid = lookthroughProc(name)
		} else {
			appId = getAppIDFromDesktopID(normalizeAppID(wmClassName))
			logger.Debug("get Pid failed, using wm class name as app id", appId)
			return appId
		}
	}
	iconName, _ := ewmh.WmIconNameGet(XU, xid)
	if pid == 0 {
		appId = normalizeAppID(wmClassName)
		logger.Debug("get window name failed, using wm class name as app id", appId)
		return appId
	} else {
	}
	appId = find_app_id(pid, name, wmInstance, wmClassName, iconName)
	appId = getAppIDFromDesktopID(normalizeAppID(appId))
	logger.Debug(fmt.Sprintf("get appid %q", appId))
	return appId
}
Пример #8
0
func (s *Setting) init() bool {
	s.core = gio.NewSettings(SchemaId)
	if s.core == nil {
		return false
	}

	s.listenSettingChange(HideModeKey, func(g *gio.Settings, key string) {
		s.hideModeLock.Lock()
		defer s.hideModeLock.Unlock()

		value := HideModeType(g.GetEnum(key))
		s.hideMode = value
		logger.Debug(key, "changed to", key)
		dbus.Emit(s, "HideModeChanged", int32(value))
	})

	s.listenSettingChange(DisplayModeKey, func(g *gio.Settings, key string) {
		s.displayModeLock.Lock()
		defer s.displayModeLock.Unlock()

		value := DisplayModeType(g.GetEnum(key))
		logger.Debug(key, "changed to", value)

		s.displayMode = value

		for _, rApp := range ENTRY_MANAGER.runtimeApps {
			rebuildXids := []xproto.Window{}
			for xid, _ := range rApp.xids {
				if _, err := xprop.PropValStr(
					xprop.GetProperty(
						XU,
						xid,
						"_DDE_DOCK_APP_ID",
					),
				); err != nil {
					continue
				}

				rebuildXids = append(rebuildXids, xid)
				rApp.detachXid(xid)
			}

			l := len(rebuildXids)
			if l == 0 {
				continue
			}

			if len(rApp.xids) == 0 {
				ENTRY_MANAGER.destroyRuntimeApp(rApp)
			}

			newApp := ENTRY_MANAGER.createRuntimeApp(rebuildXids[0])
			for i := 0; i < l; i++ {
				newApp.attachXid(rebuildXids[i])
			}

			activeXid, err := ewmh.ActiveWindowGet(XU)
			if err != nil {
				continue
			}

			for xid, _ := range newApp.xids {
				logger.Debugf("through new app xids")
				if activeXid == xid {
					logger.Debugf("0x%x(a), 0x%x(x)",
						activeXid, xid)
					newApp.setLeader(xid)
					newApp.updateState(xid)
					ewmh.ActiveWindowSet(XU, xid)
					break
				}
			}
		}

		dockProperty.updateDockHeight(value)
		dbus.Emit(s, "DisplayModeChanged", int32(value))
	})
	s.listenSettingChange(ClockTypeKey, func(*gio.Settings, string) {
		s.clockTypeLock.Lock()
		defer s.clockTypeLock.Unlock()
		s.clockType = ClockType(s.core.GetEnum(ClockTypeKey))
		dbus.Emit(s, "ClockTypeChanged", int32(s.clockType))
	})

	s.listenSettingChange(DisplayDateKey, func(*gio.Settings, string) {
		s.displayDateLock.Lock()
		defer s.displayDateLock.Unlock()
		s.displayDate = s.core.GetBoolean(DisplayDateKey)
		dbus.Emit(s, "DisplayDateChanged", s.displayDate)
	})
	s.listenSettingChange(DisplayWeekKey, func(*gio.Settings, string) {
		s.displayWeekLock.Lock()
		defer s.displayWeekLock.Unlock()
		s.displayWeek = s.core.GetBoolean(DisplayWeekKey)
		dbus.Emit(s, "DisplayWeekChanged", s.displayWeek)
	})

	// at least one read operation must be called after signal connected, otherwise,
	// the signal connection won't work from glib 2.43.
	// NB: https://github.com/GNOME/glib/commit/8ff5668a458344da22d30491e3ce726d861b3619
	s.displayMode = DisplayModeType(s.core.GetEnum(DisplayModeKey))
	s.hideMode = HideModeType(s.core.GetEnum(HideModeKey))
	if s.hideMode == HideModeAutoHide {
		s.hideMode = HideModeSmartHide
		s.core.SetEnum(HideModeKey, int32(HideModeSmartHide))
	}
	s.clockType = ClockType(s.core.GetEnum(ClockTypeKey))
	s.displayDate = s.core.GetBoolean(DisplayDateKey)
	s.displayWeek = s.core.GetBoolean(DisplayWeekKey)

	return true
}
Пример #9
0
// _NET_WM_NAME get
func WmNameGet(xu *xgbutil.XUtil, win xproto.Window) (string, error) {
	return xprop.PropValStr(xprop.GetProperty(xu, win, "_NET_WM_NAME"))
}
Пример #10
0
// _NET_WM_VISIBLE_ICON_NAME get
func WmVisibleIconNameGet(xu *xgbutil.XUtil,
	win xproto.Window) (string, error) {

	return xprop.PropValStr(xprop.GetProperty(xu, win,
		"_NET_WM_VISIBLE_ICON_NAME"))
}
Пример #11
0
// WM_CLIENT_MACHINE get
func WmClientMachineGet(xu *xgbutil.XUtil, win xproto.Window) (string, error) {
	return xprop.PropValStr(xprop.GetProperty(xu, win, "WM_CLIENT_MACHINE"))
}
Пример #12
0
func StatusGet(X *xgbutil.XUtil) bool {
	status, err := xprop.PropValStr(xprop.GetProperty(X, X.RootWin(),
		"_WINGO_CMD_STATUS"))

	return err == nil && strings.ToLower(status) == "success"
}
Пример #13
0
func CmdGet(X *xgbutil.XUtil) (string, error) {
	return xprop.PropValStr(xprop.GetProperty(X, X.RootWin(), "_WINGO_CMD"))
}