fharper / nuke-desktop

πŸ“¦ Golang package for interfacing with desktop applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

desktop

πŸ“¦ Golang package for interfacing with desktop applications

format

πŸš€ Install

go get github.com/gleich/desktop

πŸ“ Documentation

🍎 MacOS

MacOSApplications()

Get a list of all running desktop applications for the mac operating system. Returns a list containing the names of the running applications and any error that might have occurred. There is also an optional includeMenubarApps parameter: if set to true it will also include applications running in the menubar.

Example:

package main

import (
    "fmt"
    "os"

    "github.com/gleich/desktop"
)

func main() {
    apps, err := desktop.MacOSApplications(includeMenubarApps bool)
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }
}

MacOSQuitApp()

Force quit an application by passing the name of the application. Returns any error that might have occurred.

package main

import (
    "fmt"
    "os"

    "github.com/gleich/desktop"
)

func main() {
    err := desktop.MacOSQuitApp("Slack")
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }
}

🐧 Linux

LinuxApplications()

⚠️ Warning!! This function requires the wmctrl tool to be installed. Please install it with your package manager

Get a list of all running desktop applications for any linux based operating system. Returns a map containing the names of the running desktop applications and their corresponding PIDs and any error that might have occurred.

Example:

package main

import (
    "fmt"
    "os"

    "github.com/gleich/desktop"
)

func main() {
    apps, err := desktop.LinuxApplications()
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }
}

LinuxQuitApp()

Kill an application by passing the PID. Returns any error that might have occurred.

Example:

package main

import (
    "fmt"
    "os"

    "github.com/gleich/desktop"
)

func main() {
    err := desktop.LinuxQuitApp(72667)
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }
}

πŸ‘₯ Contributors

About

πŸ“¦ Golang package for interfacing with desktop applications

License:MIT License


Languages

Language:Go 82.3%Language:Dockerfile 17.7%