├── Join-AutoStart ├── Press.sh └── README.txt ├── README.md ├── main.go ├── main_!windows.go ├── main_windows.go └── template.html.go /Join-AutoStart/Press.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ "$1" == "press=:="* ]]; then 3 | key=$(echo "$1" | cut -c 9-) 4 | xdotool key $key 5 | fi 6 | -------------------------------------------------------------------------------- /Join-AutoStart/README.txt: -------------------------------------------------------------------------------- 1 | All programs in here are automatically ran by Jointercept 2 | when a Join message is received. It is ran with the 3 | message itself as a command line argument. Have fun! -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Jointercept 2 | Jointercept stands for Join Intercept and is a replacement for the buggy EventGhost to instead launch your own programs! 3 | 4 | Runs on: 5 | - Linux (Tested) 6 | - Windows (Fixed, thanks to [Kenneth Pang](https://plus.google.com/u/0/+KennethPang)) 7 | - Mac (Untested) 8 | 9 | ## Pros using Jointercept rather than a custom program: 10 | 1. Compatibility with multiple programs!! 11 | 2. Cleaner and easier code! 12 | 3. See pushes log on a website. 13 | 4. Programmed in Go. Speed is a must. 14 | ## Pros using Jointercept rather than a URL protocol: 15 | 1. Intercept all messages rather than specific ones. 16 | 2. Cross platform. 17 | 18 | ## Command line 19 | Jointercept [port] 20 | 21 | Examples: 22 | ``` 23 | Jointercept 24 | ``` 25 | ``` 26 | Jointercept 12345 27 | ``` 28 | 29 | # Usage: 30 | Just place your programs or scripts _(yes, you can invoke a program from anywhere on the computer using shell scripts)_ under the Join-AutoStart folder! It will now be called with the message as command line argument! 31 | 32 | Also, make sure to set the "EventGhost Port" in Join to whatever port you start Jointercept with! 33 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "html/template" 6 | "io/ioutil" 7 | "net/http" 8 | "os" 9 | "path/filepath" 10 | "strconv" 11 | "strings" 12 | "time" 13 | 14 | "github.com/jD91mZM2/stdutil" 15 | ) 16 | 17 | type logItem struct { 18 | Msg string 19 | Time string 20 | } 21 | 22 | var log = make([]logItem, 0) 23 | 24 | const TIME_FORMAT = "03:04:05PM" 25 | const DIR = "Join-AutoStart" 26 | 27 | var README = filepath.Join(DIR, "README.txt") 28 | 29 | const DIRINFO = "All programs in here are automatically ran by Jointercept\n" + 30 | "when a Join message is received. It is ran with the\n" + 31 | "message itself as a command line argument. Have fun!" 32 | 33 | var TEMPLATE = template.Must(template.New("main").Parse(TEMPLATE_CODE)) 34 | var TEMPLATE_TABLE = template.Must(template.New("table").Parse(TEMPLATE_CODE_TABLE)) 35 | 36 | func handler(w http.ResponseWriter, r *http.Request) { 37 | msg := r.FormValue("message") 38 | 39 | if msg != "" { 40 | now := time.Now() 41 | 42 | fmt.Println("Intercepted \"" + msg + "\"") 43 | log = append(log, logItem{ 44 | Msg: msg, 45 | Time: now.Format(TIME_FORMAT), 46 | }) 47 | 48 | mkdir() 49 | programs, err := ioutil.ReadDir(DIR) 50 | if err != nil { 51 | stdutil.PrintErr("Couldn't read directory", err) 52 | return 53 | } 54 | 55 | for _, program := range programs { 56 | name := program.Name() 57 | if strings.HasSuffix(name, ".txt") { 58 | continue 59 | } 60 | 61 | cmd := makecmd(name, msg) 62 | cmd.Dir = "Join-AutoStart" 63 | err := cmd.Start() 64 | 65 | if err != nil { 66 | stdutil.PrintErr("Warning: Couldn't start "+name, err) 67 | } 68 | } 69 | } else { 70 | TEMPLATE.Execute(w, log) 71 | } 72 | } 73 | func handlerTable(w http.ResponseWriter, r *http.Request) { 74 | TEMPLATE_TABLE.Execute(w, log) 75 | } 76 | 77 | func mkdir() { 78 | err := os.Mkdir(DIR, 0755) 79 | if err != nil && !os.IsExist(err) { 80 | stdutil.PrintErr("Error creating directory", err) 81 | } 82 | 83 | err = ioutil.WriteFile(README, []byte(DIRINFO), 0666) 84 | if err != nil && !os.IsExist(err) { 85 | stdutil.PrintErr("Error creating README", err) 86 | } 87 | } 88 | 89 | func main() { 90 | port := "8080" 91 | 92 | args := os.Args[1:] 93 | if len(args) >= 1 { 94 | _, err := strconv.Atoi(args[0]) 95 | if err == nil { 96 | port = args[0] 97 | } else { 98 | stdutil.PrintErr("Argument is not a number", nil) 99 | } 100 | } 101 | fmt.Println("Service starting at port " + port + "!") 102 | fmt.Println("Visible at http://localhost:" + port + "/. Change port in arguments.") 103 | mkdir() 104 | 105 | http.HandleFunc("/", handler) 106 | http.HandleFunc("/table", handlerTable) 107 | err := http.ListenAndServe(":"+port, nil) 108 | if err != nil { 109 | stdutil.PrintErr("Error! Couldn't serve website", err) 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /main_!windows.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package main 4 | 5 | import ( 6 | "os/exec" 7 | "strconv" 8 | ) 9 | 10 | func makecmd(name string, arg string) *exec.Cmd { 11 | return exec.Command("sh", "-c", "./"+strconv.Quote(name)+" "+strconv.Quote(arg)) 12 | } 13 | -------------------------------------------------------------------------------- /main_windows.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os/exec" 5 | ) 6 | 7 | func makecmd(name string, arg string) *exec.Cmd { 8 | return exec.Command("cmd", "/c", name, arg) 9 | } 10 | -------------------------------------------------------------------------------- /template.html.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const TEMPLATE_CODE = ` 4 | 5 | 6 | 7 | Jointercept 8 | 9 | 38 | 50 | 51 | 52 | 53 |
54 | Hello!
55 | This page is currently being used by Jointercept.
56 | You can always change ports in arguments! 57 | 58 | 59 | ` + TEMPLATE_CODE_TABLE + ` 60 |
61 |
62 | 63 | 64 | ` 65 | 66 | const TEMPLATE_CODE_TABLE = ` 67 | {{range .}} 68 | 69 | {{.Msg}} 70 | {{.Time}} 71 | 72 | {{end}} 73 | ` 74 | --------------------------------------------------------------------------------