Giter Site home page Giter Site logo

go-toast's Introduction

Beeper

A go toast notification package for Windows, Linux and macOS

Credits to:

CLI

Hacked together this small tool because I could not find a project that offered all of the features I wanted. Particularly the ability to pass a custom message and image paths as params, for all 3 commonly used platforms (Windows, macOS & Linux)

flag needs an argument: -img & -msg
Usage of C:\Example\beeper\main.go-windows-amd64.exe:
  -img string
        Enter a Custom Path (default "assets/information.png")
  -msg string
        Enter a Custom Message (default "Default BEEP BEEP!")
  -title string
        Enter a Custom Title (default "Title")

Example

This assumes you are familar with go and have a god development environment setup. The below was performed on windows, however thsi can be performed on macOS or Linux, change the commands as necessary.

  1. Make Directories and CD to beeper parent dir
C:\Example> mkdir beeper && mkdir beeper\assets
C:\Example> cd beeper
  1. Add Images to assets dir

  2. Create main go package

C:\Example\beeper> echo package main  > main.go
  1. Add Example Code
package main

import (
	"flag"
	"fmt"
	"reflect"

	"github.com/gen2brain/beeep"
)

func main() {
	//---Define the various flags---
	msgPtr := flag.String("msg", "Default BEEP BEEP!",
		"Enter a Custom Message")
	imgPth := flag.String("img", "assets/information.png",
		"Enter a Custom Path")
    titleNm := flag.String("title", "Title",
    "Enter a Custom Title")
	//---parse the command line into the defined flags---
	flag.Parse()
	err := beeep.Notify(*titleNm, *msgPtr, *imgPth)
	if err != nil {
		panic(err)
	}
	for _, arg := range flag.Args() {
		fmt.Print(arg, " ")
		fmt.Println(reflect.TypeOf(arg))
	}
}
  1. Init Directory
C:\Example\beeper> go mod init beeper
  1. Create Cross-Platform Build Bash/Bat file (On Windows I use git bash)
#!/usr/bin/env bash

package=$1
if [[ -z "$package" ]]; then
  echo "usage: $0 <package-name>"
  exit 1
fi
package_split=(${package//\// })
package_name=${package_split[-1]}
	
platforms=("windows/amd64" "windows/386" "darwin/amd64", "linux/amd64")

for platform in "${platforms[@]}"
do
	platform_split=(${platform//\// })
	GOOS=${platform_split[0]}
	GOARCH=${platform_split[1]}
	output_name=$package_name'-'$GOOS'-'$GOARCH
	if [ $GOOS = "windows" ]; then
		output_name+='.exe'
	fi	

	env GOOS=$GOOS GOARCH=$GOARCH go build -o $output_name $package
	if [ $? -ne 0 ]; then
   		echo 'An error has occurred! Aborting the script execution...'
		exit 1
	fi
done
  1. Build Binaries by running bash
$ ./build.bash main.go
  1. Test the binaries
$ ./main.go-windows-amd64.exe -img "assets/warning.png"

go-toast's People

Contributors

ttyson-adm avatar ten16thomasg avatar

Stargazers

Austin Culter avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.