Exemplo n.º 1
0
func main() {
	events, err := i3ipc.Subscribe(i3ipc.I3WorkspaceEvent)
	if err != nil {
		return
	}

	ipcsocket, err = i3ipc.GetIPCSocket()
	if err != nil {
		return
	}
	printWorkspaces()

	for {
		_ = <-events
		printWorkspaces()
	}
}
Exemplo n.º 2
0
func main() {
	if i3, err = i3ipc.GetIPCSocket(); err != nil {
		panic(err)
	}

	flag.Parse()

	if (!flagSwitchworkspace && !flagMoveContainerToWorkspace) ||
		(flagSwitchworkspace && flagMoveContainerToWorkspace) {
		usage()
	}

	// Let's get the workspace to move to with dmenu
	workspace := getWorkspace()

	if flagMoveContainerToWorkspace {
		moveContainerToWorkspace(workspace)
	} else if flagSwitchworkspace {
		selectWorkspace(workspace)
	}
}
Exemplo n.º 3
0
func main() {
	ipc, e := i3ipc.GetIPCSocket()
	checkError(e)

	tree, e := ipc.GetTree()
	checkError(e)

	var node *i3ipc.I3Node
	names, nodes := dfsTree(&tree)
	switch len(names) {
	case 0:
		os.Exit(0)
	case 1:
		node = nodes[0]
	default:
		cmd := exec.Command("dmenu", os.Args[1:len(os.Args)]...)
		cmd.Stdin = strings.NewReader(strings.Join(names, "\n"))

		out, e := cmd.Output()
		checkError(e)

		name := strings.TrimRight(string(out), "\n")

		for i, s := range names {
			if s == name {
				node = nodes[i]
				break
			}
		}
	}

	if node != nil {
		msg := fmt.Sprint("[con_id=", node.Id, "] focus")
		ipc.Raw(i3ipc.I3Command, msg)
	}
}