├── .github
├── CODEOWNERS
├── workflows
│ ├── dependency.yml
│ ├── tag.yml
│ ├── test.yml
│ └── release.yml
├── dependabot.yml
├── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
└── codeql.yml
├── Dockerfile
├── .gitignore
├── .idea
├── vcs.xml
├── .gitignore
├── modules.xml
├── recursive-backup.iml
└── watcherTasks.xml
├── .dockerignore
├── utils
├── date
│ └── main.go
└── replace
│ └── main.go
├── docker-compose.yml
├── main.go
├── .editorconfig
├── .prettierrc
├── CITATION.cff
├── .vscode
├── launch.json
└── settings.json
├── Vagrantfile
├── Makefile
├── commands
├── version.go
├── manual.go
└── root.go
├── ps
├── notify.go
└── notify_test.go
├── session
├── session_test.go
├── session_windows.go
├── session_darwin.go
├── session_linux.go
└── session.go
├── go.mod
├── progress_bar
└── model.go
├── CONTRIBUTING.md
├── CODE_OF_CONDUCT.md
├── README.md
├── .goreleaser.yml
├── go.sum
└── LICENSE.md
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | /.github/CODEOWNERS @AppleGamer22
2 | * @AppleGamer22
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM kdeneon/plasma
2 | RUN sudo apt-get update && sudo apt-get install -y golang git
3 | WORKDIR /home/neon
4 | COPY . .
5 | CMD go test -v -race -cover ./session ./ps ./commands
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.csv
2 | *.exe
3 | cocainate
4 | cocainate.bash
5 | cocainate.fish
6 | cocainate.zsh
7 | cocainate.ps1
8 | cocainate.1
9 | bin
10 | vendor
11 | .vagrant
12 | **/.DS_Store
13 | dist/
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.dockerignore:
--------------------------------------------------------------------------------
1 | AppleGamer22.cocainate.yml
2 | README.md
3 | cocainate.rb
4 | CITATION.cff
5 | LICENSE.md
6 | Vagrantfile
7 | CODE_OF_CONDUCT.md
8 | CONTRIBUTING.md
9 | PKGBUILD
10 | cocainate.1
11 | .goreleaser.yml
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Datasource local storage ignored files
5 | /dataSources/
6 | /dataSources.local.xml
7 | # Editor-based HTTP Client requests
8 | /httpRequests/
9 |
--------------------------------------------------------------------------------
/utils/date/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "time"
6 | )
7 |
8 | func main() {
9 | now := time.Now()
10 | year := now.Year()
11 | month := now.Month()
12 | day := now.Day()
13 | fmt.Printf("%d-%02d-%02d\n", year, month, day)
14 | }
15 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3"
2 | services:
3 | cocainate:
4 | container_name: cocainate
5 | build: .
6 | # security_opt:
7 | # - seccomp=unconfined
8 | # environment:
9 | # - DISPLAY=:0
10 | # volumes:
11 | # - /tmp/.X11-unix:/tmp/.X11-unix
--------------------------------------------------------------------------------
/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "os"
5 |
6 | "github.com/AppleGamer22/cocainate/commands"
7 | )
8 |
9 | func main() {
10 | if err := commands.RootCommand.Execute(); err != nil {
11 | // _, _ = fmt.Fprintf(os.Stderr, "%v\n", err)
12 | os.Exit(1)
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*.md]
4 | max_line_length = off
5 | trim_trailing_whitespace = false
6 |
7 | [*.{yml, yaml}]
8 | indent_style = space
9 | indent_size = 2
10 |
11 | [*]
12 | charset = utf-8
13 | indent_style = tab
14 | indent_size = 4
15 | insert_final_newline = false
16 | trim_trailing_whitespace = true
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": false,
3 | "trailingComma": "all",
4 | "tabWidth": 4,
5 | "arrowParens": "avoid",
6 | "useTabs": true,
7 | "semi": true,
8 | "overrides": [
9 | {
10 | "files": ["*.yml", "*.yaml"],
11 | "options": {
12 | "tabWidth": 2,
13 | "useTabs": false
14 | }
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/.idea/recursive-backup.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/CITATION.cff:
--------------------------------------------------------------------------------
1 | # yaml-language-server: $schema=https://citation-file-format.github.io/1.2.0/schema.json
2 | cff-version: 1.2.0
3 | message: "If you use this software, please cite it as below."
4 | authors:
5 | - family-names: Bornstein
6 | given-names: Omri
7 | title: cocainate
8 | version: 1.0.0
9 | date-released: 2022-03-12
10 | url: https://github.com/AppleGamer22/cocainate
11 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Launch Package",
9 | "type": "go",
10 | "request": "launch",
11 | "mode": "auto",
12 | "program": "${fileDirname}"
13 | }
14 | ]
15 | }
--------------------------------------------------------------------------------
/.github/workflows/dependency.yml:
--------------------------------------------------------------------------------
1 | name: Dependency Review
2 | on:
3 | pull_request:
4 | types:
5 | - opened
6 | - closed
7 | - reopened
8 | permissions:
9 | contents: read
10 | jobs:
11 | dependency:
12 | runs-on: ubuntu-latest
13 | steps:
14 | - name: Pull Source Code
15 | uses: actions/checkout@v6.0.1
16 | - name: Dependency Review
17 | uses: actions/dependency-review-action@v4
18 | with:
19 | fail-on-severity: low
20 |
--------------------------------------------------------------------------------
/.github/workflows/tag.yml:
--------------------------------------------------------------------------------
1 | name: Update Documentation
2 | on:
3 | push:
4 | tags: ['v*']
5 | jobs:
6 | publish_docs:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - name: Set-up Go
10 | uses: actions/setup-go@v6.1.0
11 | with:
12 | go-version: stable
13 | - name: Get version
14 | id: get_version
15 | run: echo ::set-output name=VERSION::${GITHUB_REF##*/v}
16 | - name: Publish Documentation
17 | run: GOPROXY=https://proxy.golang.org GO111MODULE=on go install github.com/AppleGamer22/cocainate@v${{steps.get_version.outputs.VERSION}}
18 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: gomod
4 | directory: /
5 | schedule:
6 | interval: daily
7 | assignees:
8 | - AppleGamer22
9 | reviewers:
10 | - AppleGamer22
11 | commit-message:
12 | prefix: chore
13 | labels:
14 | - dependencies
15 | - package-ecosystem: github-actions
16 | directory: /
17 | schedule:
18 | interval: daily
19 | assignees:
20 | - AppleGamer22
21 | reviewers:
22 | - AppleGamer22
23 | commit-message:
24 | prefix: chore
25 | labels:
26 | - dependencies
--------------------------------------------------------------------------------
/Vagrantfile:
--------------------------------------------------------------------------------
1 | Vagrant.configure("2") do |config|
2 | config.ssh.insert_key = false
3 | config.vm.provider "virtualbox" do |virtualbox|
4 | virtualbox.memory = 2048
5 | virtualbox.cpus = 2
6 | virtualbox.gui = false
7 | virtualbox.name = "cocainate"
8 | end
9 | config.vm.box = "ubuntu/focal64"
10 | config.vm.hostname = "ubuntu"
11 | config.vm.synced_folder ".", "/home/vagrant/Documents/cocainate", create: true
12 | config.vm.provision "shell", inline: <<-SCRIPT
13 | # sudo apt update && sudo apt upgrade -y
14 | # sudo apt install -y ubuntu-desktop-minimal
15 | # sudo systemctl start gdm3
16 | SCRIPT
17 | end
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "cSpell.words": [
3 | "aurs",
4 | "caffeinate",
5 | "cocainate",
6 | "codeql",
7 | "dbus",
8 | "goarch",
9 | "goreleaser",
10 | "inhibitation",
11 | "ldflags",
12 | "nfpms",
13 | "optdepends",
14 | "paru",
15 | "pkgdir",
16 | "rber",
17 | "rberrors",
18 | "riscv",
19 | "roff"
20 | ],
21 | "files.associations": {
22 | "*.cff": "yaml"
23 | },
24 | "[yaml]": {
25 | "editor.insertSpaces": true,
26 | "editor.tabSize": 2,
27 | "editor.detectIndentation": false,
28 | },
29 | "[yml]": {
30 | "editor.insertSpaces": true,
31 | "editor.tabSize": 2,
32 | "editor.detectIndentation": false,
33 | }
34 | }
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/codeql.yml:
--------------------------------------------------------------------------------
1 | name: CodeQL
2 | on:
3 | pull_request:
4 | types:
5 | - opened
6 | - closed
7 | - reopened
8 | workflow_dispatch:
9 | inputs: {}
10 | jobs:
11 | analyze:
12 | name: Analyze
13 | runs-on: ubuntu-latest
14 | permissions:
15 | actions: read
16 | contents: read
17 | security-events: write
18 | steps:
19 | - name: Pull Source Code
20 | uses: actions/checkout@v3
21 | - name: Set-up Go
22 | uses: actions/setup-go@v3
23 | with:
24 | go-version: "1.19.2"
25 | - name: Initialize CodeQL
26 | uses: github/codeql-action/init@v2
27 | with:
28 | languages: go
29 | - name: Build
30 | run: make debug
31 | - name: Perform CodeQL Analysis
32 | uses: github/codeql-action/analyze@v2
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Test
2 | on:
3 | pull_request:
4 | types:
5 | - opened
6 | - closed
7 | - reopened
8 | workflow_dispatch:
9 | inputs: {}
10 | jobs:
11 | test:
12 | strategy:
13 | fail-fast: false
14 | matrix:
15 | os:
16 | # - ubuntu-latest
17 | - macos-latest
18 | - windows-latest
19 | runs-on: ${{matrix.os}}
20 | steps:
21 | - name: Pull Source Code
22 | uses: actions/checkout@v6.0.1
23 | - name: Install Linux-only Dependencies
24 | if: matrix.os == 'ubuntu-latest'
25 | run: |
26 | # sudo apt install -y ubuntu-desktop-minimal
27 | # sudo systemctl isolate graphical
28 | # sudo systemctl start gdm3
29 | - name: Set-up Go
30 | uses: actions/setup-go@v6.1.0
31 | with:
32 | go-version: stable
33 | - name: Test
34 | run: |
35 | go mod tidy
36 | make test
37 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | VERSION:=$(shell git describe --tags --abbrev=0)
2 | HASH:=$(shell git rev-list -1 HEAD)
3 | PACKAGE:=github.com/AppleGamer22/cocainate
4 | LDFLAGS:=-ldflags="-X '$(PACKAGE)/commands.Version=$(subst v,,$(VERSION))' -X '$(PACKAGE)/commands.Hash=$(HASH)'"
5 |
6 | test:
7 | go clean -testcache
8 | go test -v -race -cover ./session ./ps ./commands
9 |
10 | debug:
11 | go build $(LDFLAGS) .
12 |
13 | completion:
14 | go run . completion bash > cocainate.bash
15 | go run . completion fish > cocainate.fish
16 | go run . completion zsh > cocainate.zsh
17 | go run . completion powershell > cocainate.ps1
18 |
19 | manual:
20 | # go run ./utils/replace cocainate.1 -b "vVERSION" -a "$(VERSION)"
21 | # go run ./utils/replace cocainate.1 -b "DATE" -a "$(shell go run ./utils/date)"
22 | # go run . manual | man -l -
23 | go run . manual > cocainate.1
24 |
25 | clean:
26 | rm -rf cocainate bin dist cocainate.bash cocainate.fish cocainate.zsh cocainate.ps1
27 | go clean -testcache -cache
28 |
29 | .PHONY: debug test clean completion manual
30 |
--------------------------------------------------------------------------------
/commands/version.go:
--------------------------------------------------------------------------------
1 | package commands
2 |
3 | import (
4 | "fmt"
5 | "runtime"
6 |
7 | "github.com/spf13/cobra"
8 | )
9 |
10 | var (
11 | Version = "development"
12 | Hash = "development"
13 | Date = "2006-01-02"
14 |
15 | verbose bool
16 |
17 | versionCommand = &cobra.Command{
18 | Use: "version",
19 | Short: "print version",
20 | Long: "print version",
21 | Run: func(cmd *cobra.Command, args []string) {
22 | if verbose {
23 | if Version != "development" {
24 | fmt.Printf("version: \t%s\n", Version)
25 | }
26 |
27 | if Hash != "development" {
28 | fmt.Printf("commit: \t%s\n", Hash)
29 | }
30 | fmt.Printf("compiler: \t%s (%s)\n", runtime.Version(), runtime.Compiler)
31 | fmt.Printf("platform: \t%s/%s\n", runtime.GOOS, runtime.GOARCH)
32 | } else {
33 | fmt.Println(Version)
34 | }
35 | },
36 | }
37 | )
38 |
39 | func init() {
40 | versionCommand.Flags().BoolVarP(&verbose, "verbose", "v", false, "version, git commit hash, compiler version & platform")
41 | RootCommand.AddCommand(versionCommand)
42 | }
43 |
--------------------------------------------------------------------------------
/ps/notify.go:
--------------------------------------------------------------------------------
1 | package ps
2 |
3 | import (
4 | "errors"
5 | "os"
6 | "time"
7 |
8 | "github.com/shirou/gopsutil/process"
9 | )
10 |
11 | /*
12 | Generate a channel for termination signal from an external process (with PID).
13 |
14 | A polling interval is used as delay between process checks.
15 | */
16 | func Notify(pid int32, pollingDuration time.Duration) chan error {
17 | errs := make(chan error, 1)
18 |
19 | abort := pid == 0 || pid == int32(os.Getpid()) && pollingDuration <= 0
20 |
21 | if abort {
22 | errs <- errors.New("invalid PID or process polling interval, both must be non-0")
23 | return errs
24 | }
25 |
26 | go func() {
27 | ticker := time.NewTicker(pollingDuration)
28 | for range ticker.C {
29 | p, err := process.NewProcess(pid)
30 | if err != nil {
31 | errs <- nil
32 | break
33 | }
34 |
35 | if running, err := p.IsRunning(); err != nil || !running {
36 | // if err != nil, a race condition has occurred, the process ended after checking for its existence but before checking if it's running
37 | errs <- nil
38 | break
39 | }
40 | }
41 | }()
42 | return errs
43 | }
44 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 | on:
3 | push:
4 | tags:
5 | - 'v*'
6 | - '!*alpha*'
7 | - '!*beta*'
8 | - '!*rc*'
9 | permissions:
10 | contents: write
11 | jobs:
12 | github_release:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Pull Source Code
16 | uses: actions/checkout@v6.0.1
17 | with:
18 | fetch-depth: 0
19 | - name: Fetch All Tags
20 | run: git fetch --force --tags
21 | - name: Set-up Go
22 | uses: actions/setup-go@v6.1.0
23 | with:
24 | go-version: stable
25 | - name: Set-up Syft
26 | uses: anchore/sbom-action/download-syft@v0.20.11
27 | - name: Set-up Nix
28 | uses: cachix/install-nix-action@v31
29 | with:
30 | github_access_token: ${{secrets.GITHUB_TOKEN}}
31 | - name: Build, Package & Distribute
32 | uses: goreleaser/goreleaser-action@v6
33 | with:
34 | distribution: goreleaser
35 | version: latest
36 | args: release --clean
37 | env:
38 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
39 | TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
40 | AUR_SSH_PRIVATE_KEY: ${{secrets.AUR_SSH_PRIVATE_KEY}}
41 |
--------------------------------------------------------------------------------
/.idea/watcherTasks.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/ps/notify_test.go:
--------------------------------------------------------------------------------
1 | package ps_test
2 |
3 | import (
4 | "os/exec"
5 | "runtime"
6 | "sync"
7 | "testing"
8 | "time"
9 |
10 | "github.com/AppleGamer22/cocainate/ps"
11 | "github.com/shirou/gopsutil/process"
12 | "github.com/stretchr/testify/assert"
13 | )
14 |
15 | func TestNotify(t *testing.T) {
16 | var wg sync.WaitGroup
17 | wg.Add(3)
18 |
19 | cmd := func() *exec.Cmd {
20 | if runtime.GOOS != "windows" {
21 | return exec.Command("man", "man")
22 | }
23 | return exec.Command("powershell", "-c", "pause", ">", "$null")
24 | }()
25 |
26 | err := cmd.Start()
27 | assert.NoError(t, err)
28 | assert.NotNil(t, cmd.Process)
29 | pid := cmd.Process.Pid
30 | exists, err := process.PidExists(int32(pid))
31 | assert.NoError(t, err)
32 | assert.True(t, exists)
33 |
34 | go func() {
35 | err := cmd.Wait()
36 | assert.Error(t, err)
37 | wg.Done()
38 | }()
39 |
40 | go func() {
41 | err := <-ps.Notify(int32(pid), time.Nanosecond)
42 | assert.NoError(t, err)
43 | wg.Done()
44 | }()
45 |
46 | go func() {
47 | time.Sleep(time.Nanosecond * 5)
48 | // for range time.NewTicker(time.Nanosecond).C {
49 | // if exists, err := process.PidExists(int32(pid)); exists && err == nil {
50 | // break
51 | // }
52 | // }
53 | err := cmd.Process.Kill()
54 | assert.NoError(t, err)
55 | wg.Done()
56 | }()
57 |
58 | wg.Wait()
59 | }
60 |
--------------------------------------------------------------------------------
/commands/manual.go:
--------------------------------------------------------------------------------
1 | package commands
2 |
3 | import (
4 | "fmt"
5 |
6 | mango "github.com/muesli/mango-cobra"
7 | "github.com/muesli/roff"
8 | "github.com/spf13/cobra"
9 | )
10 |
11 | var manualCommand = &cobra.Command{
12 | Use: "manual",
13 | Short: "print manual page",
14 | Long: "print manual page to standard output",
15 | RunE: func(cmd *cobra.Command, args []string) error {
16 | manualPage, err := mango.NewManPage(1, RootCommand)
17 | if err != nil {
18 | return err
19 | }
20 |
21 | manualPage.WithSection("Bugs", fmt.Sprintf("Please report bugs to our GitHub page https://github.com/AppleGamer22/%s/issues", manualPage.Root.Name))
22 | manualPage.WithSection("Authors", "Omri Bornstein ")
23 | manualPage.WithSection("Copyright", `cocainate is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
24 | cocainate is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.`)
25 | _, err = fmt.Println(manualPage.Build(roff.NewDocument()))
26 | return err
27 | },
28 | }
29 |
30 | func init() {
31 | RootCommand.AddCommand(manualCommand)
32 | }
33 |
--------------------------------------------------------------------------------
/commands/root.go:
--------------------------------------------------------------------------------
1 | package commands
2 |
3 | import (
4 | "errors"
5 | "flag"
6 | "fmt"
7 | "time"
8 |
9 | "github.com/AppleGamer22/cocainate/session"
10 | "github.com/spf13/cobra"
11 | )
12 |
13 | var (
14 | duration time.Duration
15 | pid int
16 | quiet bool
17 | )
18 |
19 | var RootCommand = &cobra.Command{
20 | Use: "cocainate",
21 | Short: "keep screen awake",
22 | Long: "keep screen awake",
23 | Version: Version,
24 | Args: func(cmd *cobra.Command, args []string) error {
25 | if pid != 0 && duration == 0 {
26 | return errors.New("process poling interval must be provided via the -d flag")
27 | }
28 | return nil
29 | },
30 | RunE: func(cmd *cobra.Command, args []string) error {
31 | s := session.New(duration, pid)
32 |
33 | if err := s.Start(); err != nil {
34 | return err
35 | }
36 |
37 | if err := s.Wait(quiet); err != nil {
38 | return err
39 | }
40 |
41 | if flag.Lookup("test.v") == nil {
42 | fmt.Print("\r")
43 | }
44 |
45 | return nil
46 | },
47 | }
48 |
49 | func init() {
50 | RootCommand.Flags().DurationVarP(&duration, "duration", "d", 0, "duration with units ns, us (or µs), ms, s, m, h")
51 | RootCommand.Flags().IntVarP(&pid, "pid", "p", 0, "a running process ID, duration (used as polling interval) must be provided")
52 | RootCommand.Flags().BoolVarP(&quiet, "quiet", "q", false, "hide progress bar")
53 | // RootCommand.MarkFlagsRequiredTogether("pid", "duration")
54 | RootCommand.SetVersionTemplate("{{.Version}}\n")
55 | }
56 |
--------------------------------------------------------------------------------
/session/session_test.go:
--------------------------------------------------------------------------------
1 | package session_test
2 |
3 | import (
4 | "sync"
5 | "testing"
6 | "time"
7 |
8 | "github.com/AppleGamer22/cocainate/session"
9 |
10 | "github.com/stretchr/testify/assert"
11 | )
12 |
13 | // Test for session duration
14 | func TestDuration(t *testing.T) {
15 | s := session.New(time.Nanosecond, 0)
16 | err := s.Start()
17 | assert.NoError(t, err)
18 |
19 | err = s.Wait(true)
20 | assert.NoError(t, err)
21 | }
22 |
23 | // Test for session interrupt signal
24 | func TestInterrupt(t *testing.T) {
25 | s := session.New(0, 0)
26 | err := s.Start()
27 | assert.NoError(t, err)
28 |
29 | err = s.Kill()
30 | assert.NoError(t, err)
31 |
32 | err = s.Wait(true)
33 | assert.NoError(t, err)
34 | }
35 |
36 | // Test for session programmatic stop while Wait is running
37 | func TestKill(t *testing.T) {
38 | s := session.New(0, 0)
39 | err := s.Start()
40 | assert.NoError(t, err)
41 |
42 | var wg sync.WaitGroup
43 | wg.Add(2)
44 |
45 | go func() {
46 | err := s.Wait(false)
47 | assert.NoError(t, err)
48 | wg.Done()
49 | }()
50 |
51 | go func() {
52 | err := s.Kill()
53 | assert.NoError(t, err)
54 | wg.Done()
55 | }()
56 |
57 | wg.Wait()
58 | }
59 |
60 | // Test for session programmatic stop while Wait is not running
61 | func TestStop(t *testing.T) {
62 | s := session.New(0, 0)
63 | err := s.Start()
64 | assert.NoError(t, err)
65 |
66 | err = s.Stop()
67 | assert.NoError(t, err)
68 | }
69 |
70 | // Test for when Wait is called before Start
71 | func TestErrors(t *testing.T) {
72 | s := session.New(0, 0)
73 | err := s.Wait(false)
74 | assert.Error(t, err)
75 |
76 | err = s.Kill()
77 | assert.Error(t, err)
78 | }
79 |
--------------------------------------------------------------------------------
/utils/replace/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "bufio"
5 | "bytes"
6 | "errors"
7 | "fmt"
8 | "io"
9 | "os"
10 | "strings"
11 |
12 | "github.com/spf13/cobra"
13 | )
14 |
15 | var before, after string
16 |
17 | var rootCommand = cobra.Command{
18 | Args: func(_ *cobra.Command, args []string) error {
19 | if len(args) != 1 {
20 | return errors.New("the file path argument is required")
21 | }
22 | _, err := os.Stat(args[0])
23 | return err
24 | },
25 | PreRunE: func(_ *cobra.Command, args []string) error {
26 | if before == "" || (before == "" && after == "") {
27 | return errors.New("invalid replacement argument(s)")
28 | }
29 | return nil
30 | },
31 | RunE: func(_ *cobra.Command, args []string) error {
32 | path := args[0]
33 | file, err := os.OpenFile(path, os.O_RDWR, 0)
34 | if err != nil {
35 | return err
36 | }
37 | defer file.Close()
38 | scanner := bufio.NewScanner(file)
39 | var buffer bytes.Buffer
40 | for scanner.Scan() {
41 | line := scanner.Text()
42 | updatedLine := strings.ReplaceAll(line, before, after)
43 | if _, err := fmt.Fprintln(&buffer, updatedLine); err != nil {
44 | return err
45 | }
46 | }
47 | if err := scanner.Err(); err != nil {
48 | return err
49 | }
50 | if _, err := file.Seek(0, io.SeekStart); err != nil {
51 | return err
52 | }
53 | _, err = io.Copy(file, &buffer)
54 | return err
55 | },
56 | }
57 |
58 | func init() {
59 | rootCommand.Flags().StringVarP(&before, "before", "b", "", "")
60 | rootCommand.Flags().StringVarP(&after, "after", "a", "", "")
61 | }
62 |
63 | func main() {
64 | if err := rootCommand.Execute(); err != nil {
65 | os.Exit(1)
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/session/session_windows.go:
--------------------------------------------------------------------------------
1 | package session
2 |
3 | import (
4 | "errors"
5 | "os"
6 | "sync"
7 | "syscall"
8 | "time"
9 | )
10 |
11 | const (
12 | esContinuous = 0x80000000
13 | esSystemRequired = 0x00000001
14 | )
15 |
16 | type Session struct {
17 | sync.Mutex
18 | PID int
19 | Duration time.Duration
20 | Signals chan os.Signal
21 | active bool
22 | }
23 |
24 | /*
25 | Starts a SetThreadExecutionState session (https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate).
26 |
27 | A non-nil error is returned if the session failed to start.
28 | */
29 | func (s *Session) Start() error {
30 | kernel32 := syscall.NewLazyDLL("kernel32.dll")
31 | setThreadExecStateProc := kernel32.NewProc("SetThreadExecutionState")
32 | r1, _, err := setThreadExecStateProc.Call(uintptr(esContinuous | esSystemRequired))
33 | if r1 == 0 {
34 | return err
35 | }
36 |
37 | s.Lock()
38 | s.active = true
39 | s.Unlock()
40 | return nil
41 | }
42 |
43 | /*
44 | Stop kills an already-started session while Wait is not running in the background.
45 |
46 | This method is recommended for uses in which the session is required to terminate only by the calling program, and not by the user.
47 | */
48 | func (s *Session) Stop() error {
49 | if !s.Active() {
50 | return errors.New("Stop can be called only after Start has been called successfully")
51 | }
52 |
53 | kernel32 := syscall.NewLazyDLL("kernel32.dll")
54 | setThreadExecStateProc := kernel32.NewProc("SetThreadExecutionState")
55 | r1, _, err := setThreadExecStateProc.Call(uintptr(esContinuous))
56 | if r1 == 0 {
57 | return err
58 | }
59 |
60 | s.Lock()
61 | s.active = false
62 | s.Unlock()
63 | return nil
64 | }
65 |
66 | // A Boolean for session status
67 | func (s *Session) Active() bool {
68 | return s.active
69 | }
70 |
--------------------------------------------------------------------------------
/session/session_darwin.go:
--------------------------------------------------------------------------------
1 | package session
2 |
3 | import (
4 | "errors"
5 | "os"
6 | "os/exec"
7 | "sync"
8 | "time"
9 | )
10 |
11 | type Session struct {
12 | sync.Mutex
13 | PID int
14 | Duration time.Duration
15 | Signals chan os.Signal
16 | caffeinate *exec.Cmd
17 | }
18 |
19 | /*
20 | Starts a caffeinate (https://github.com/apple-oss-distributions/PowerManagement/tree/main/caffeinate) session.
21 |
22 | A non-nil error is returned if the session failed to start.
23 | */
24 | func (s *Session) Start() error {
25 | // if session.Duration > 0 {
26 | // args = append(args, "-t")
27 | // seconds := fmt.Sprintf("%d", int(session.Duration.Round(time.Second)))
28 | // args = append(args, seconds)
29 | // }
30 |
31 | // if session.PID != 0 && session.PID != os.Getpid() {
32 | // args = append(args, "-w")
33 | // pid := fmt.Sprintf("%d", session.PID)
34 | // args = append(args, pid)
35 | // }
36 |
37 | s.Lock()
38 | defer s.Unlock()
39 | s.caffeinate = exec.Command("caffeinate", "-diu")
40 | if err := s.caffeinate.Start(); err != nil {
41 | return err
42 | }
43 |
44 | return nil
45 | }
46 |
47 | /*
48 | Stop kills an already-started session while Wait is not running in the background.
49 |
50 | This method is recommended for uses in which the session is required to terminate only by the calling program, and not by the user.
51 | */
52 | func (s *Session) Stop() error {
53 | if !s.Active() {
54 | return errors.New("Stop can be called only after Start has been called successfully")
55 | }
56 |
57 | if err := s.caffeinate.Process.Kill(); err != nil {
58 | return err
59 | }
60 |
61 | s.Lock()
62 | defer s.Unlock()
63 | s.caffeinate = nil
64 | return nil
65 | }
66 |
67 | // A Boolean for session status
68 | func (s *Session) Active() bool {
69 | return s.caffeinate != nil
70 | }
71 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/AppleGamer22/cocainate
2 |
3 | go 1.24.0
4 |
5 | require (
6 | github.com/charmbracelet/bubbles v0.21.0
7 | github.com/charmbracelet/bubbletea v1.3.10
8 | github.com/charmbracelet/lipgloss v1.1.0
9 | github.com/godbus/dbus/v5 v5.2.0
10 | github.com/muesli/mango-cobra v1.3.0
11 | github.com/muesli/roff v0.1.0
12 | github.com/shirou/gopsutil v3.21.11+incompatible
13 | github.com/spf13/cobra v1.10.2
14 | github.com/stretchr/testify v1.11.1
15 | )
16 |
17 | require (
18 | github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
19 | github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
20 | github.com/charmbracelet/harmonica v0.2.0 // indirect
21 | github.com/charmbracelet/x/ansi v0.10.1 // indirect
22 | github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
23 | github.com/charmbracelet/x/term v0.2.1 // indirect
24 | github.com/davecgh/go-spew v1.1.1 // indirect
25 | github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
26 | github.com/go-ole/go-ole v1.2.6 // indirect
27 | github.com/inconshreveable/mousetrap v1.1.0 // indirect
28 | github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
29 | github.com/mattn/go-isatty v0.0.20 // indirect
30 | github.com/mattn/go-localereader v0.0.1 // indirect
31 | github.com/mattn/go-runewidth v0.0.16 // indirect
32 | github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
33 | github.com/muesli/cancelreader v0.2.2 // indirect
34 | github.com/muesli/mango v0.2.0 // indirect
35 | github.com/muesli/mango-pflag v0.1.0 // indirect
36 | github.com/muesli/termenv v0.16.0 // indirect
37 | github.com/pmezard/go-difflib v1.0.0 // indirect
38 | github.com/rivo/uniseg v0.4.7 // indirect
39 | github.com/spf13/pflag v1.0.9 // indirect
40 | github.com/tklauser/go-sysconf v0.3.10 // indirect
41 | github.com/tklauser/numcpus v0.5.0 // indirect
42 | github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
43 | github.com/yusufpapurcu/wmi v1.2.2 // indirect
44 | golang.org/x/sys v0.36.0 // indirect
45 | golang.org/x/text v0.3.8 // indirect
46 | gopkg.in/yaml.v3 v3.0.1 // indirect
47 | )
48 |
--------------------------------------------------------------------------------
/progress_bar/model.go:
--------------------------------------------------------------------------------
1 | package progress_bar
2 |
3 | import (
4 | "fmt"
5 | "os"
6 | "time"
7 |
8 | "github.com/charmbracelet/bubbles/progress"
9 | tea "github.com/charmbracelet/bubbletea"
10 | "github.com/charmbracelet/lipgloss"
11 | )
12 |
13 | const (
14 | // padding = 2
15 | maxWidth = 80
16 | )
17 |
18 | var (
19 | quitMessage = tea.Sequence(tea.ShowCursor, tea.Quit)
20 | helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FFFFFF")).Render
21 | )
22 |
23 | type model struct {
24 | duration time.Duration
25 | amount float64
26 | percentage float64
27 | p progress.Model
28 | }
29 |
30 | func New(duration time.Duration, signals chan os.Signal) *tea.Program {
31 | m := &model{
32 | duration: duration,
33 | amount: 1 / duration.Seconds(),
34 | percentage: 0,
35 | p: progress.New(progress.WithSolidFill("#FFFFFF")),
36 | }
37 |
38 | program := tea.NewProgram(m)
39 | go func() {
40 | program.Run()
41 | signals <- os.Interrupt
42 | }()
43 | return program
44 | }
45 |
46 | func (m model) Init() tea.Cmd {
47 | return tickCommand()
48 | }
49 |
50 | func (m model) Update(message tea.Msg) (tea.Model, tea.Cmd) {
51 | switch message := message.(type) {
52 | case tea.KeyMsg:
53 | return m, quitMessage
54 | case tea.WindowSizeMsg:
55 | m.p.Width = message.Width
56 | if m.p.Width > maxWidth {
57 | m.p.Width = maxWidth
58 | }
59 | return m, nil
60 | case time.Time:
61 | m.percentage += m.amount
62 | if m.percentage >= 1.0 {
63 | m.percentage = 1.0
64 | return m, quitMessage
65 | }
66 | return m, renderMessage()
67 | default:
68 | return m, nil
69 | }
70 |
71 | }
72 |
73 | func (m model) View() string {
74 | if m.percentage >= 1.0 {
75 | return ""
76 | }
77 | return fmt.Sprintf(
78 | "%s\n%s/%s\n%s",
79 | m.p.ViewAs(m.percentage),
80 | time.Duration(float64(m.duration)*m.percentage).Round(time.Second), m.duration,
81 | helpStyle("Press any key to quit"),
82 | )
83 | }
84 |
85 | func tickCommand() tea.Cmd {
86 | return tea.Tick(time.Second, func(t time.Time) tea.Msg {
87 | return t
88 | })
89 | }
90 |
91 | func renderMessage() tea.Cmd {
92 | return tea.Sequence(tea.ShowCursor, tickCommand())
93 | }
94 |
--------------------------------------------------------------------------------
/session/session_linux.go:
--------------------------------------------------------------------------------
1 | package session
2 |
3 | import (
4 | "errors"
5 | "os"
6 | "sync"
7 | "time"
8 |
9 | dbus "github.com/godbus/dbus/v5"
10 | )
11 |
12 | const (
13 | path = "/org/freedesktop/ScreenSaver"
14 | screensaver = "org.freedesktop.ScreenSaver"
15 | inhibit = "org.freedesktop.ScreenSaver.Inhibit"
16 | uninhibit = "org.freedesktop.ScreenSaver.UnInhibit"
17 | )
18 |
19 | type Session struct {
20 | sync.Mutex
21 | PID int
22 | Duration time.Duration
23 | Signals chan os.Signal
24 | cookie uint32
25 | }
26 |
27 | /*
28 | Starts the session (according to https://people.freedesktop.org/~hadess/idle-inhibition-spec/re01.html) with a call to the D-BUS screensaver inhibitor.
29 |
30 | A non-nil error is returned if the D-BUS session connection fails, if the inhabitation call fails or if the cookie recovery fails.
31 | */
32 | func (s *Session) Start() error {
33 | connection, err := dbus.SessionBus()
34 | if err != nil {
35 | return err
36 | }
37 | defer connection.Close()
38 |
39 | object := connection.Object(screensaver, path)
40 | call := object.Call(inhibit, 0, "cocainate", "cocainate is running")
41 |
42 | if call.Err != nil {
43 | return call.Err
44 | }
45 | s.Lock()
46 | defer s.Unlock()
47 | if err := call.Store(&s.cookie); err != nil {
48 | return err
49 | }
50 |
51 | return nil
52 | }
53 |
54 | /*
55 | Stop kills an already-started session while Wait is not running in the background.
56 |
57 | This method is recommended for uses in which the session is required to terminate only by the calling program, and not by the user.
58 | */
59 | func (s *Session) Stop() error {
60 | if !s.Active() {
61 | return errors.New("Stop can be called only after Start has been called successfully")
62 | }
63 |
64 | connection, err := dbus.SessionBus()
65 | if err != nil {
66 | return err
67 | }
68 | defer connection.Close()
69 |
70 | s.Lock()
71 | defer s.Unlock()
72 | object := connection.Object(screensaver, path)
73 | err = object.Call(uninhibit, 0, s.cookie).Err
74 | if err != nil {
75 | return err
76 | }
77 |
78 | s.cookie = 0
79 | return nil
80 | }
81 |
82 | // A Boolean for session status
83 | func (s *Session) Active() bool {
84 | return s.cookie != 0
85 | }
86 |
--------------------------------------------------------------------------------
/session/session.go:
--------------------------------------------------------------------------------
1 | package session
2 |
3 | import (
4 | "errors"
5 | "fmt"
6 | "os"
7 | "os/signal"
8 | "syscall"
9 | "time"
10 |
11 | "github.com/AppleGamer22/cocainate/progress_bar"
12 | "github.com/AppleGamer22/cocainate/ps"
13 | tea "github.com/charmbracelet/bubbletea"
14 | )
15 |
16 | /*
17 | Creates a New session instance with duration.
18 |
19 | If the session's duration is 0, the session will stop after a termination signal or a call to session.Stop.
20 | */
21 | func New(duration time.Duration, pid int) *Session {
22 | s := Session{
23 | Duration: duration,
24 | PID: pid,
25 | Signals: make(chan os.Signal, 1),
26 | }
27 | signal.Notify(s.Signals, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
28 | return &s
29 | }
30 |
31 | /*
32 | Wait can be called only after Start has been called successfully.
33 |
34 | Wait will block further execution until the user send an interrupt signal, or until the session duration has passed.
35 |
36 | A non-nil error is returned if the un-inhabitation call fails.
37 | */
38 | func (s *Session) Wait(quiet bool) error {
39 | if !s.Active() {
40 | return errors.New("Wait can be called only after Start has been called successfully")
41 | }
42 |
43 | if s.Duration > 0 && s.PID != 0 && s.PID != os.Getppid() && s.PID != os.Getpid() {
44 | select {
45 | case psError := <-ps.Notify(int32(s.PID), s.Duration):
46 | if stoppingError := s.Stop(); stoppingError != nil && psError != nil {
47 | return fmt.Errorf("%v\n%v", psError, stoppingError)
48 | } else {
49 | return psError
50 | }
51 | case <-s.Signals:
52 | }
53 | } else if s.Duration > 0 {
54 | var program *tea.Program
55 | if !quiet {
56 | program = progress_bar.New(s.Duration, s.Signals)
57 | }
58 | // https://pkg.go.dev/time#After
59 | timer := time.NewTimer(s.Duration)
60 | select {
61 | case <-timer.C:
62 | if !quiet {
63 | program.Wait()
64 | }
65 | case <-s.Signals:
66 | timer.Stop()
67 | if !quiet {
68 | program.Kill()
69 | }
70 | }
71 | } else {
72 | <-s.Signals
73 | }
74 |
75 | return s.Stop()
76 | }
77 |
78 | /*
79 | Kill terminates the current session.
80 |
81 | Can be called only when Wait is running in the background.
82 | */
83 | func (s *Session) Kill() error {
84 | if s.Signals == nil || !s.Active() {
85 | return errors.New("Start has not been called successfully or Wait is not running in the background")
86 | }
87 |
88 | s.Lock()
89 | s.Signals <- os.Interrupt
90 | s.Unlock()
91 | return nil
92 | }
93 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to `cocainate`
2 | We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
3 | * Reporting a bug
4 | * Discussing the current state of the code
5 | * Submitting a fix
6 | * Proposing new features
7 | * Becoming a maintainer
8 |
9 | ## [Questions/Problems](https://github.com/AppleGamer22/cocainate/discussions)
10 | We use GitHub Discussions to answer your questions that might not require an issue ad a pull request.
11 |
12 | Available discussion categories:
13 | * [General](https://github.com/AppleGamer22/cocainate/discussions/categories/general)
14 | * [Ideas](https://github.com/AppleGamer22/cocainate/discussions/categories/ideas)
15 | * Discussion categories changes should be suggested here.
16 | * [Q&A](https://github.com/AppleGamer22/cocainate/discussions/categories/q-a)
17 | * [Show & Tell](https://github.com/AppleGamer22/cocainate/discussions/categories/show-tell)
18 |
19 | ## [Submissions](https://guides.github.com/introduction/flow/index.html)
20 | Pull requests are the best way to propose changes to the codebase (we use Github Flow). We actively welcome your pull requests:
21 |
22 | > The following workflow uses the [GitHub CLI](https://cli.github.com/) for illustration purposes, so feel free to use other Git compatible tools that you are familiar with.
23 |
24 | >.svg?cdnVersion=1393)
25 | > Atlassian. (2021). Gitflow Workflow. Atlassian; Atlassian. https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow
26 |
27 |
28 |
29 | 1. Fork the repo and create your branch from `master`/`main`.
30 | ```bash
31 | # Clone your fork of the repo into the current directory
32 | git clone https://github.com/AppleGamer22/cocainate
33 | # Navigate to the newly cloned directory
34 | cd cocainate
35 | # Assign the original repo to a remote called "GitHub"
36 | git remote add GitHub https://github.com/AppleGamer22/cocainate
37 | # Create a new branch from HEAD
38 | git branch
39 | ```
40 | 2. If you've added code that should be tested, add tests (`.spec.ts` files).
41 | 3. If you've changed APIs, update the [documentation](https://tsdoc.org/).
42 | 4. Ensure the test suite passes.
43 | ```bash
44 | # Run library tests
45 | go test ./session ./ps
46 | ```
47 | 5. Commit & push your changes to your branch
48 | ```bash
49 | # Commit all changed files with a message
50 | git commit -am ""
51 | # Push changes to your remote GitHub branch
52 | git push GitHub
53 | ```
54 | 6. [Create a pull request](https://cli.github.com/manual/gh_pr_create)
55 | ```bash
56 | gh pr create [flags]
57 | ```
58 | 7. [Mark a pull request as ready for review](https://cli.github.com/manual/gh_pr_ready) if appropriate
59 | ```bash
60 | gh pr ready [ | | ] [flags]
61 | ```
62 | 8. Wait for others to review the pull request
63 | 9. [Close the pull request](https://cli.github.com/manual/gh_pr_close) if appropriate
64 | ```bash
65 | gh pr close [ | | ] [flags]
66 | ```
67 |
68 | ## [Bug Reports/Feature Requests](https://github.com/AppleGamer22/cocainate/issues)
69 | We use GitHub Issues to track public bugs. Report a bug by opening a new issue.
70 |
71 | Your bug reports should have:
72 | * A quick summary and/or background
73 | * Steps to reproduce with:
74 | * Shell commands
75 | * Sample code
76 | * Configuration files
77 | * Expected behaviour
78 | * Actual behaviour
79 | * Notes about:
80 | * including why you think this might be happening,
81 | * or stuff you tried that didn't work
82 |
83 | ## [Coding Style](https://editorconfig.org/)
84 | Our `.editorconfig` file:
85 | ```toml
86 | root = true
87 |
88 | [*]
89 | charset = utf-8
90 | indent_style = tab
91 | indent_size = 4
92 | insert_final_newline = false
93 | trim_trailing_whitespace = true
94 |
95 | [*.md]
96 | max_line_length = off
97 | trim_trailing_whitespace = false
98 |
99 | [*.{yml, yaml}]
100 | indent_style = space
101 | indent_size = 2
102 | ```
103 | ## [License](https://github.com/AppleGamer22/cocainate/blob/master/LICENSE.md)
104 | When you submit code changes, your submissions are understood to be under the same [GNU GPL-3 License](https://choosealicense.com/licenses/gpl-3.0/) that covers the project. Feel free to contact the maintainers if that's a concern.
105 |
106 | By contributing, you agree that your contributions will be licensed under its GNU GPL-3 License.
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 | ## Our Pledge
3 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body
4 | size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status,
5 | nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
6 |
7 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8 |
9 | ## Our Standards
10 | Examples of behavior that contributes to a positive environment for our community include:
11 |
12 | * Demonstrating empathy and kindness toward other people
13 | * Being respectful of differing opinions, viewpoints, and experiences
14 | * Giving and gracefully accepting constructive feedback
15 | * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
16 | * Focusing on what is best not just for us as individuals, but for the overall community
17 |
18 | Examples of unacceptable behavior include:
19 |
20 | * The use of sexualized language or imagery, and sexual attention or advances of any kind
21 | * Trolling, insulting or derogatory comments, and personal or political attacks
22 | * Public or private harassment
23 | * Publishing others' private information, such as a physical or email address, without their explicit permission
24 | * Other conduct which could reasonably be considered inappropriate in a professional setting
25 |
26 | ## Enforcement Responsibilities
27 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
28 |
29 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
30 |
31 | ## Scope
32 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
33 |
34 | ## Enforcement
35 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [omribor@gmail.com](mailto:omribor@gmail.com). All complaints will be reviewed and investigated promptly and fairly.
36 |
37 | All community leaders are obligated to respect the privacy and security of the reporter of any incident.
38 |
39 | ## Enforcement Guidelines
40 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
41 |
42 | ### 1. Correction
43 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
44 |
45 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
46 |
47 | ### 2. Warning
48 | **Community Impact**: A violation through a single incident or series of actions.
49 |
50 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
51 |
52 | ### 3. Temporary Ban
53 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
54 |
55 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
56 |
57 | ### 4. Permanent Ban
58 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
59 |
60 | **Consequence**: A permanent ban from any sort of public interaction within the community.
61 |
62 | ## Attribution
63 | This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).
64 |
65 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
66 |
67 | For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are available at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations).
68 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # `cocainate`
2 | [](https://pkg.go.dev/github.com/AppleGamer22/cocainate) [](https://github.com/AppleGamer22/cocainate/actions/workflows/test.yml) [](https://github.com/AppleGamer22/cocainate/actions/workflows/codeql.yml) [](https://github.com/AppleGamer22/cocainate/actions/workflows/release.yml) [](https://github.com/AppleGamer22/cocainate/actions/workflows/tag.yml)
3 |
4 | ## Description
5 | `cocainate` is a cross-platform CLI utility for keeping the screen awake until stopped, or for a specified duration.
6 |
7 | ## Why This Name?
8 | The program's functionality and name are inspired by [macOS's `caffeinate`](https://github.com/apple-oss-distributions/PowerManagement/blob/main/caffeinate) utility that prevents the system from entering sleep mode.
9 |
10 | This name is simply a stupid ~~pun~~, therefore **I do not condone and do not promote drug use**, for more information: [Wikipedia](https://en.wikipedia.org/wiki/Cocaine_(song)).
11 |
12 | ## Installation
13 | ### Nix Flakes
14 | ```nix
15 | {
16 | inputs = {
17 | # or your preferred NixOS channel
18 | nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
19 | applegamer22.url = "github:AppleGamer22/nur";
20 | };
21 | outputs = { nixpkgs }: {
22 | nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
23 | specialArgs = {
24 | pkgs = import nixpkgs {
25 | # ...
26 | overlays = [
27 | (final: prev: {
28 | # ...
29 | ag22 = applegamer22.packages."";
30 | })
31 | ];
32 | };
33 | };
34 | modules = [
35 | # or in a separate Nix file
36 | ({ pkgs, ... }: {
37 | programs.nix-ld.enable = true;
38 | environment.systemPackages = with pkgs; [
39 | ag22.cocainate
40 | ];
41 | })
42 | # ...
43 | ];
44 | };
45 | };
46 | }
47 | ```
48 | ### Arch Linux Distributions
49 | * [`yay`](https://github.com/Jguer/yay):
50 | ```bash
51 | yay -S cocainate-bin
52 | ```
53 | * [`paru`](https://github.com/morganamilo/paru):
54 | ```bash
55 | paru -S cocainate-bin
56 | ```
57 |
58 | ### macOS
59 | * [Homebrew Tap](https://github.com/AppleGamer22/homebrew-tap):
60 | ```bash
61 | brew install AppleGamer22/tap/cocainate
62 | ```
63 |
64 | ### Windows (working progress)
65 | * [`winget`](https://github.com/microsoft/winget-cli):
66 | ```bash
67 | winget install AppleGamer22.cocainate
68 | ```
69 | ### Other
70 | * `go`:
71 | * Does not ship with:
72 | * a manual page
73 | * pre-built shell completion scripts
74 | ```
75 | go install github.com/AppleGamer22/cocainate
76 | ```
77 |
78 | ## Functionality
79 | ### Root `-d`/`--duration` Flag
80 | This is an optional flag that accepts a duration string (see [Go's `time.ParseDuration`](https://pkg.go.dev/time#ParseDuration) for more details). If this flag is not provided, the program will run until manually stopped.
81 |
82 | #### Acceptable Time Units
83 | * nanoseconds: *`ns`*
84 | * microseconds: *`us`* or *`µs`*
85 | * milliseconds: *`ms`*
86 | * seconds: *`s`*
87 | * minutes: *`m`*
88 | * hours: *`h`*
89 |
90 | #### Examples
91 | * 10 hours: `-d 10h`
92 | * 1 hour, 10 minutes and 10 seconds: `-d 1h10m10s`
93 | * 1 microsecond: `-d 1us`
94 |
95 | If the `-p` flag is provided, the `-d` flag's value is used as process polling interval.
96 |
97 | ### Root `-p`/`--pid` Flag
98 | This is an optional flag that accepts a process ID (PID). If a valid PID is provided, the program will wait until that process is terminated. The delay between the termination of the provided process and the termination of screensaver inhibitation depends on the `-d` flag (which must be provided).
99 |
100 | ### `version` Sub-command
101 | #### `-v`/`--verbose` Flag
102 | * If this flag is provided, the following details are printed to the screen:
103 | 1. semantic version number
104 | 2. commit hash
105 | 3. Go compiler version
106 | 4. processor architecture & operating system
107 | * Otherwise, only the semantic version number is printed.
108 |
109 | ## Dependencies
110 | ### Linux
111 | * [D-Bus](https://www.freedesktop.org/wiki/Software/dbus/)
112 | * One of the following desktop environments:
113 | * [KDE](https://kde.org) 4 or later
114 | * [GNOME](https://gnome.org) 3.10 or later
115 | * Any other desktop environment that implements [`org.freedesktop.ScreenSaver`](https://people.freedesktop.org/~hadess/idle-inhibition-spec/re01.html)
116 |
117 |
120 |
121 | ## Common Contributor Routines
122 | ### Testing
123 | Running the following command will run `go test` on the commands and session sub-modules:
124 | ```bash
125 | make test
126 | ```
127 | ### Building From Source
128 | #### Development
129 | * Using the following `make` command will save a `cocainate` binary with the last version tag and the latest git commit hash:
130 | ```bash
131 | make debug
132 | ```
133 |
134 | #### Release
135 | * Using the following [GoReleaser](https://github.com/goreleaser/goreleaser) command with a version `git` tag and a clean `git` state:
136 | ```bash
137 | goreleaser build --clean
138 | ```
139 | * All release artificats will stored in the `dist` child directory in the codebase's root directory:
140 | * compressed package archives with:
141 | * a `cocainate` binary
142 | * manual page
143 | * shell completion scripts
144 | * checksums
145 | * change log
146 |
147 | ## Copyright
148 | `cocainate` is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
149 |
150 | `cocainate` is distributed in the hope that it will be useful, but **WITHOUT ANY WARRANTY**; without even the implied warranty of **MERCHANTABILITY** or **FITNESS FOR A PARTICULAR PURPOSE**. See the GNU General Public License for more details.
--------------------------------------------------------------------------------
/.goreleaser.yml:
--------------------------------------------------------------------------------
1 | # yaml-language-server: $schema=https://goreleaser.com/static/schema.json
2 | version: 2
3 | project_name: cocainate
4 | before:
5 | hooks:
6 | - make completion manual
7 | builds:
8 | - id: linux
9 | goos:
10 | - linux
11 | goarch:
12 | - amd64
13 | - arm64
14 | - riscv64
15 | ldflags:
16 | - -X 'github.com/AppleGamer22/{{.ProjectName}}/commands.Version={{.Version}}'
17 | - -X 'github.com/AppleGamer22/{{.ProjectName}}/commands.Hash={{.FullCommit}}'
18 | - id: mac
19 | goos:
20 | - darwin
21 | goarch:
22 | - amd64
23 | - arm64
24 | ldflags:
25 | - -X 'github.com/AppleGamer22/{{.ProjectName}}/commands.Version={{.Version}}'
26 | - -X 'github.com/AppleGamer22/{{.ProjectName}}/commands.Hash={{.FullCommit}}'
27 | - id: windows
28 | goos:
29 | - windows
30 | goarch:
31 | - amd64
32 | - arm64
33 | ldflags:
34 | - -X 'github.com/AppleGamer22/{{.ProjectName}}/commands.Version={{.Version}}'
35 | - -X 'github.com/AppleGamer22/{{.ProjectName}}/commands.Hash={{.FullCommit}}'
36 | archives:
37 | - id: unix
38 | builds:
39 | - linux
40 | - mac
41 | name_template: >-
42 | {{- .ProjectName}}_
43 | {{- .Version}}_
44 | {{- if eq .Os "darwin"}}mac{{else}}
45 | {{- .Os}}
46 | {{- end}}_
47 | {{- .Arch}}
48 | files:
49 | - "{{.ProjectName}}.bash"
50 | - "{{.ProjectName}}.fish"
51 | - "{{.ProjectName}}.zsh"
52 | - "{{.ProjectName}}.1"
53 | - id: windows
54 | builds:
55 | - windows
56 | format_overrides:
57 | - goos: windows
58 | format: zip
59 | name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}_{{.Arch}}"
60 | files:
61 | - "{{.ProjectName}}.ps1"
62 | - "{{.ProjectName}}.1"
63 | nfpms:
64 | - vendor: AppleGamer22
65 | maintainer: Omri Bornstein
66 | homepage: https://github.com/AppleGamer22/{{.ProjectName}}
67 | license: GPL-3.0
68 | description: Cross-platform caffeinate alternative.
69 | file_name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}_{{.Arch}}"
70 | builds:
71 | - linux
72 | dependencies:
73 | - dbus
74 | formats:
75 | - apk
76 | - deb
77 | - rpm
78 | - archlinux
79 | contents:
80 | - src: "{{.ProjectName}}.1"
81 | dst: /usr/share/man/man1/{{.ProjectName}}.1
82 | - src: "{{.ProjectName}}.bash"
83 | dst: /usr/share/bash-completion/completions/{{.ProjectName}}
84 | - src: "{{.ProjectName}}.fish"
85 | dst: /usr/share/fish/completions/{{.ProjectName}}.fish
86 | - src: "{{.ProjectName}}.zsh"
87 | dst: /usr/share/zsh/site-functions/_{{.ProjectName}}
88 | changelog:
89 | use: github
90 | filters:
91 | exclude:
92 | - '^docs:'
93 | - '^test:'
94 | - '^chore'
95 | - typo
96 | - Merge pull request
97 | - Merge remote-tracking branch
98 | - Merge branch
99 | - go mod tidy
100 | groups:
101 | - title: 'New Features'
102 | regexp: "^.*feat[(\\w)]*:+.*$"
103 | order: 0
104 | - title: 'Bug fixes'
105 | regexp: "^.*fix[(\\w)]*:+.*$"
106 | order: 10
107 | - title: Other work
108 | order: 999
109 | release:
110 | github:
111 | owner: AppleGamer22
112 | name: "{{.ProjectName}}"
113 | discussion_category_name: General
114 | footer: |
115 | ## Installation
116 | ### Nix Flakes
117 | ```nix
118 | {
119 | inputs = {
120 | # or your preferred NixOS channel
121 | nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
122 | applegamer22.url = "github:AppleGamer22/nur";
123 | };
124 | outputs = { nixpkgs }: {
125 | nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
126 | specialArgs = {
127 | pkgs = import nixpkgs {
128 | # ...
129 | overlays = [
130 | (final: prev: {
131 | # ...
132 | ag22 = applegamer22.packages."";
133 | })
134 | ];
135 | };
136 | };
137 | modules = [
138 | # or in a separate Nix file
139 | ({ pkgs, ... }: {
140 | programs.nix-ld.enable = true;
141 | environment.systemPackages = with pkgs; [
142 | ag22.{{.ProjectName}}
143 | ];
144 | })
145 | # ...
146 | ];
147 | };
148 | };
149 | }
150 | ```
151 | ### Arch Linux Distributions
152 | * [`yay`](https://github.com/Jguer/yay):
153 | ```bash
154 | yay -S {{.ProjectName}}-bin
155 | ```
156 | * [`paru`](https://github.com/morganamilo/paru):
157 | ```bash
158 | paru -S {{.ProjectName}}-bin
159 | ```
160 |
161 | ### macOS
162 | * [Homebrew Tap](https://github.com/AppleGamer22/homebrew-tap):
163 | ```bash
164 | brew install AppleGamer22/tap/{{.ProjectName}}
165 | ```
166 | prerelease: auto
167 | nix:
168 | - repository:
169 | owner: AppleGamer22
170 | name: nur
171 | token: "{{.Env.TAP_GITHUB_TOKEN}}"
172 | commit_author:
173 | name: Omri Bornstein
174 | email: omribor@gmail.com
175 | homepage: https://github.com/AppleGamer22/{{.ProjectName}}
176 | description: Cross-platform caffeinate alternative.
177 | license: gpl3Only
178 | ids:
179 | - unix
180 | install: |
181 | mkdir -p $out/bin
182 | cp -vr ./{{.ProjectName}} $out/bin/{{.ProjectName}}
183 | installManPage ./{{.ProjectName}}.1
184 | installShellCompletion ./{{.ProjectName}}.*sh
185 | brews:
186 | - repository:
187 | owner: AppleGamer22
188 | name: homebrew-tap
189 | token: "{{.Env.TAP_GITHUB_TOKEN}}"
190 | download_strategy: CurlDownloadStrategy
191 | commit_author:
192 | name: Omri Bornstein
193 | email: omribor@gmail.com
194 | homepage: https://github.com/AppleGamer22/{{.ProjectName}}
195 | description: Cross-platform caffeinate alternative.
196 | license: GPL-3.0
197 | install: |
198 | bin.install "{{.ProjectName}}"
199 | man1.install "{{.ProjectName}}.1"
200 | bash_completion.install "{{.ProjectName}}.bash" => "{{.ProjectName}}"
201 | fish_completion.install "{{.ProjectName}}.fish"
202 | zsh_completion.install "{{.ProjectName}}.zsh" => "_{{.ProjectName}}"
203 | aurs:
204 | - homepage: https://github.com/AppleGamer22/{{.ProjectName}}
205 | description: Cross-platform caffeinate alternative.
206 | license: GPL3
207 | maintainers:
208 | - Omri Bornstein
209 | contributors:
210 | - Omri Bornstein
211 | private_key: "{{.Env.AUR_SSH_PRIVATE_KEY}}"
212 | git_url: ssh://aur@aur.archlinux.org/{{.ProjectName}}-bin.git
213 | depends:
214 | - dbus
215 | optdepends:
216 | - bash
217 | - fish
218 | - zsh
219 | package: |
220 | install -Dm755 {{.ProjectName}} "${pkgdir}/usr/bin/{{.ProjectName}}"
221 | install -Dm644 {{.ProjectName}}.1 "${pkgdir}/usr/share/man/man1/{{.ProjectName}}.1"
222 | install -Dm644 {{.ProjectName}}.bash "${pkgdir}/usr/share/bash-completion/completions/{{.ProjectName}}"
223 | install -Dm644 {{.ProjectName}}.fish "${pkgdir}/usr/share/fish/vendor_completions.d/{{.ProjectName}}.fish"
224 | install -Dm644 {{.ProjectName}}.zsh "${pkgdir}/usr/share/zsh/site-functions/_{{.ProjectName}}"
225 | commit_author:
226 | name: Omri Bornstein
227 | email: omribor@gmail.com
228 | sboms:
229 | - artifacts: archive
--------------------------------------------------------------------------------
/go.sum:
--------------------------------------------------------------------------------
1 | github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
2 | github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
3 | github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs=
4 | github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg=
5 | github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw=
6 | github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
7 | github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
8 | github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
9 | github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
10 | github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
11 | github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
12 | github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
13 | github.com/charmbracelet/x/ansi v0.10.1 h1:rL3Koar5XvX0pHGfovN03f5cxLbCF2YvLeyz7D2jVDQ=
14 | github.com/charmbracelet/x/ansi v0.10.1/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
15 | github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8=
16 | github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
17 | github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
18 | github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
19 | github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
20 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
21 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
22 | github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
23 | github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
24 | github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
25 | github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
26 | github.com/godbus/dbus/v5 v5.2.0 h1:3WexO+U+yg9T70v9FdHr9kCxYlazaAXUhx2VMkbfax8=
27 | github.com/godbus/dbus/v5 v5.2.0/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c=
28 | github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
29 | github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
30 | github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
31 | github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
32 | github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
33 | github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
34 | github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
35 | github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
36 | github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
37 | github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
38 | github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
39 | github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
40 | github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
41 | github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
42 | github.com/muesli/mango v0.2.0 h1:iNNc0c5VLQ6fsMgAqGQofByNUBH2Q2nEbD6TaI+5yyQ=
43 | github.com/muesli/mango v0.2.0/go.mod h1:5XFpbC8jY5UUv89YQciiXNlbi+iJgt29VDC5xbzrLL4=
44 | github.com/muesli/mango-cobra v1.3.0 h1:vQy5GvPg3ndOSpduxutqFoINhWk3vD5K2dXo5E8pqec=
45 | github.com/muesli/mango-cobra v1.3.0/go.mod h1:Cj1ZrBu3806Qw7UjxnAUgE+7tllUBj1NCLQDwwGx19E=
46 | github.com/muesli/mango-pflag v0.1.0 h1:UADqbYgpUyRoBja3g6LUL+3LErjpsOwaC9ywvBWe7Sg=
47 | github.com/muesli/mango-pflag v0.1.0/go.mod h1:YEQomTxaCUp8PrbhFh10UfbhbQrM/xJ4i2PB8VTLLW0=
48 | github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8=
49 | github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig=
50 | github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
51 | github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
52 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
53 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
54 | github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
55 | github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
56 | github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
57 | github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
58 | github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
59 | github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
60 | github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
61 | github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
62 | github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
63 | github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
64 | github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
65 | github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
66 | github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
67 | github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
68 | github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
69 | github.com/tklauser/numcpus v0.5.0 h1:ooe7gN0fg6myJ0EKoTAf5hebTZrH52px3New/D9iJ+A=
70 | github.com/tklauser/numcpus v0.5.0/go.mod h1:OGzpTxpcIMNGYQdit2BYL1pvk/dSOaJWjKoflh+RQjo=
71 | github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
72 | github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
73 | github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
74 | github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
75 | go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
76 | golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
77 | golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
78 | golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
79 | golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
80 | golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
81 | golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
82 | golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
83 | golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
84 | golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
85 | golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
86 | golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
87 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
88 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
89 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
90 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
91 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | ### GNU GENERAL PUBLIC LICENSE
2 |
3 | Version 3, 29 June 2007
4 |
5 | Copyright (C) 2007 Free Software Foundation, Inc.
6 |
7 |
8 | Everyone is permitted to copy and distribute verbatim copies of this
9 | license document, but changing it is not allowed.
10 |
11 | ### Preamble
12 |
13 | The GNU General Public License is a free, copyleft license for
14 | software and other kinds of works.
15 |
16 | The licenses for most software and other practical works are designed
17 | to take away your freedom to share and change the works. By contrast,
18 | the GNU General Public License is intended to guarantee your freedom
19 | to share and change all versions of a program--to make sure it remains
20 | free software for all its users. We, the Free Software Foundation, use
21 | the GNU General Public License for most of our software; it applies
22 | also to any other work released this way by its authors. You can apply
23 | it to your programs, too.
24 |
25 | When we speak of free software, we are referring to freedom, not
26 | price. Our General Public Licenses are designed to make sure that you
27 | have the freedom to distribute copies of free software (and charge for
28 | them if you wish), that you receive source code or can get it if you
29 | want it, that you can change the software or use pieces of it in new
30 | free programs, and that you know you can do these things.
31 |
32 | To protect your rights, we need to prevent others from denying you
33 | these rights or asking you to surrender the rights. Therefore, you
34 | have certain responsibilities if you distribute copies of the
35 | software, or if you modify it: responsibilities to respect the freedom
36 | of others.
37 |
38 | For example, if you distribute copies of such a program, whether
39 | gratis or for a fee, you must pass on to the recipients the same
40 | freedoms that you received. You must make sure that they, too, receive
41 | or can get the source code. And you must show them these terms so they
42 | know their rights.
43 |
44 | Developers that use the GNU GPL protect your rights with two steps:
45 | (1) assert copyright on the software, and (2) offer you this License
46 | giving you legal permission to copy, distribute and/or modify it.
47 |
48 | For the developers' and authors' protection, the GPL clearly explains
49 | that there is no warranty for this free software. For both users' and
50 | authors' sake, the GPL requires that modified versions be marked as
51 | changed, so that their problems will not be attributed erroneously to
52 | authors of previous versions.
53 |
54 | Some devices are designed to deny users access to install or run
55 | modified versions of the software inside them, although the
56 | manufacturer can do so. This is fundamentally incompatible with the
57 | aim of protecting users' freedom to change the software. The
58 | systematic pattern of such abuse occurs in the area of products for
59 | individuals to use, which is precisely where it is most unacceptable.
60 | Therefore, we have designed this version of the GPL to prohibit the
61 | practice for those products. If such problems arise substantially in
62 | other domains, we stand ready to extend this provision to those
63 | domains in future versions of the GPL, as needed to protect the
64 | freedom of users.
65 |
66 | Finally, every program is threatened constantly by software patents.
67 | States should not allow patents to restrict development and use of
68 | software on general-purpose computers, but in those that do, we wish
69 | to avoid the special danger that patents applied to a free program
70 | could make it effectively proprietary. To prevent this, the GPL
71 | assures that patents cannot be used to render the program non-free.
72 |
73 | The precise terms and conditions for copying, distribution and
74 | modification follow.
75 |
76 | ### TERMS AND CONDITIONS
77 |
78 | #### 0. Definitions.
79 |
80 | "This License" refers to version 3 of the GNU General Public License.
81 |
82 | "Copyright" also means copyright-like laws that apply to other kinds
83 | of works, such as semiconductor masks.
84 |
85 | "The Program" refers to any copyrightable work licensed under this
86 | License. Each licensee is addressed as "you". "Licensees" and
87 | "recipients" may be individuals or organizations.
88 |
89 | To "modify" a work means to copy from or adapt all or part of the work
90 | in a fashion requiring copyright permission, other than the making of
91 | an exact copy. The resulting work is called a "modified version" of
92 | the earlier work or a work "based on" the earlier work.
93 |
94 | A "covered work" means either the unmodified Program or a work based
95 | on the Program.
96 |
97 | To "propagate" a work means to do anything with it that, without
98 | permission, would make you directly or secondarily liable for
99 | infringement under applicable copyright law, except executing it on a
100 | computer or modifying a private copy. Propagation includes copying,
101 | distribution (with or without modification), making available to the
102 | public, and in some countries other activities as well.
103 |
104 | To "convey" a work means any kind of propagation that enables other
105 | parties to make or receive copies. Mere interaction with a user
106 | through a computer network, with no transfer of a copy, is not
107 | conveying.
108 |
109 | An interactive user interface displays "Appropriate Legal Notices" to
110 | the extent that it includes a convenient and prominently visible
111 | feature that (1) displays an appropriate copyright notice, and (2)
112 | tells the user that there is no warranty for the work (except to the
113 | extent that warranties are provided), that licensees may convey the
114 | work under this License, and how to view a copy of this License. If
115 | the interface presents a list of user commands or options, such as a
116 | menu, a prominent item in the list meets this criterion.
117 |
118 | #### 1. Source Code.
119 |
120 | The "source code" for a work means the preferred form of the work for
121 | making modifications to it. "Object code" means any non-source form of
122 | a work.
123 |
124 | A "Standard Interface" means an interface that either is an official
125 | standard defined by a recognized standards body, or, in the case of
126 | interfaces specified for a particular programming language, one that
127 | is widely used among developers working in that language.
128 |
129 | The "System Libraries" of an executable work include anything, other
130 | than the work as a whole, that (a) is included in the normal form of
131 | packaging a Major Component, but which is not part of that Major
132 | Component, and (b) serves only to enable use of the work with that
133 | Major Component, or to implement a Standard Interface for which an
134 | implementation is available to the public in source code form. A
135 | "Major Component", in this context, means a major essential component
136 | (kernel, window system, and so on) of the specific operating system
137 | (if any) on which the executable work runs, or a compiler used to
138 | produce the work, or an object code interpreter used to run it.
139 |
140 | The "Corresponding Source" for a work in object code form means all
141 | the source code needed to generate, install, and (for an executable
142 | work) run the object code and to modify the work, including scripts to
143 | control those activities. However, it does not include the work's
144 | System Libraries, or general-purpose tools or generally available free
145 | programs which are used unmodified in performing those activities but
146 | which are not part of the work. For example, Corresponding Source
147 | includes interface definition files associated with source files for
148 | the work, and the source code for shared libraries and dynamically
149 | linked subprograms that the work is specifically designed to require,
150 | such as by intimate data communication or control flow between those
151 | subprograms and other parts of the work.
152 |
153 | The Corresponding Source need not include anything that users can
154 | regenerate automatically from other parts of the Corresponding Source.
155 |
156 | The Corresponding Source for a work in source code form is that same
157 | work.
158 |
159 | #### 2. Basic Permissions.
160 |
161 | All rights granted under this License are granted for the term of
162 | copyright on the Program, and are irrevocable provided the stated
163 | conditions are met. This License explicitly affirms your unlimited
164 | permission to run the unmodified Program. The output from running a
165 | covered work is covered by this License only if the output, given its
166 | content, constitutes a covered work. This License acknowledges your
167 | rights of fair use or other equivalent, as provided by copyright law.
168 |
169 | You may make, run and propagate covered works that you do not convey,
170 | without conditions so long as your license otherwise remains in force.
171 | You may convey covered works to others for the sole purpose of having
172 | them make modifications exclusively for you, or provide you with
173 | facilities for running those works, provided that you comply with the
174 | terms of this License in conveying all material for which you do not
175 | control copyright. Those thus making or running the covered works for
176 | you must do so exclusively on your behalf, under your direction and
177 | control, on terms that prohibit them from making any copies of your
178 | copyrighted material outside their relationship with you.
179 |
180 | Conveying under any other circumstances is permitted solely under the
181 | conditions stated below. Sublicensing is not allowed; section 10 makes
182 | it unnecessary.
183 |
184 | #### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
185 |
186 | No covered work shall be deemed part of an effective technological
187 | measure under any applicable law fulfilling obligations under article
188 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
189 | similar laws prohibiting or restricting circumvention of such
190 | measures.
191 |
192 | When you convey a covered work, you waive any legal power to forbid
193 | circumvention of technological measures to the extent such
194 | circumvention is effected by exercising rights under this License with
195 | respect to the covered work, and you disclaim any intention to limit
196 | operation or modification of the work as a means of enforcing, against
197 | the work's users, your or third parties' legal rights to forbid
198 | circumvention of technological measures.
199 |
200 | #### 4. Conveying Verbatim Copies.
201 |
202 | You may convey verbatim copies of the Program's source code as you
203 | receive it, in any medium, provided that you conspicuously and
204 | appropriately publish on each copy an appropriate copyright notice;
205 | keep intact all notices stating that this License and any
206 | non-permissive terms added in accord with section 7 apply to the code;
207 | keep intact all notices of the absence of any warranty; and give all
208 | recipients a copy of this License along with the Program.
209 |
210 | You may charge any price or no price for each copy that you convey,
211 | and you may offer support or warranty protection for a fee.
212 |
213 | #### 5. Conveying Modified Source Versions.
214 |
215 | You may convey a work based on the Program, or the modifications to
216 | produce it from the Program, in the form of source code under the
217 | terms of section 4, provided that you also meet all of these
218 | conditions:
219 |
220 | - a) The work must carry prominent notices stating that you modified
221 | it, and giving a relevant date.
222 | - b) The work must carry prominent notices stating that it is
223 | released under this License and any conditions added under
224 | section 7. This requirement modifies the requirement in section 4
225 | to "keep intact all notices".
226 | - c) You must license the entire work, as a whole, under this
227 | License to anyone who comes into possession of a copy. This
228 | License will therefore apply, along with any applicable section 7
229 | additional terms, to the whole of the work, and all its parts,
230 | regardless of how they are packaged. This License gives no
231 | permission to license the work in any other way, but it does not
232 | invalidate such permission if you have separately received it.
233 | - d) If the work has interactive user interfaces, each must display
234 | Appropriate Legal Notices; however, if the Program has interactive
235 | interfaces that do not display Appropriate Legal Notices, your
236 | work need not make them do so.
237 |
238 | A compilation of a covered work with other separate and independent
239 | works, which are not by their nature extensions of the covered work,
240 | and which are not combined with it such as to form a larger program,
241 | in or on a volume of a storage or distribution medium, is called an
242 | "aggregate" if the compilation and its resulting copyright are not
243 | used to limit the access or legal rights of the compilation's users
244 | beyond what the individual works permit. Inclusion of a covered work
245 | in an aggregate does not cause this License to apply to the other
246 | parts of the aggregate.
247 |
248 | #### 6. Conveying Non-Source Forms.
249 |
250 | You may convey a covered work in object code form under the terms of
251 | sections 4 and 5, provided that you also convey the machine-readable
252 | Corresponding Source under the terms of this License, in one of these
253 | ways:
254 |
255 | - a) Convey the object code in, or embodied in, a physical product
256 | (including a physical distribution medium), accompanied by the
257 | Corresponding Source fixed on a durable physical medium
258 | customarily used for software interchange.
259 | - b) Convey the object code in, or embodied in, a physical product
260 | (including a physical distribution medium), accompanied by a
261 | written offer, valid for at least three years and valid for as
262 | long as you offer spare parts or customer support for that product
263 | model, to give anyone who possesses the object code either (1) a
264 | copy of the Corresponding Source for all the software in the
265 | product that is covered by this License, on a durable physical
266 | medium customarily used for software interchange, for a price no
267 | more than your reasonable cost of physically performing this
268 | conveying of source, or (2) access to copy the Corresponding
269 | Source from a network server at no charge.
270 | - c) Convey individual copies of the object code with a copy of the
271 | written offer to provide the Corresponding Source. This
272 | alternative is allowed only occasionally and noncommercially, and
273 | only if you received the object code with such an offer, in accord
274 | with subsection 6b.
275 | - d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 | - e) Convey the object code using peer-to-peer transmission,
288 | provided you inform other peers where the object code and
289 | Corresponding Source of the work are being offered to the general
290 | public at no charge under subsection 6d.
291 |
292 | A separable portion of the object code, whose source code is excluded
293 | from the Corresponding Source as a System Library, need not be
294 | included in conveying the object code work.
295 |
296 | A "User Product" is either (1) a "consumer product", which means any
297 | tangible personal property which is normally used for personal,
298 | family, or household purposes, or (2) anything designed or sold for
299 | incorporation into a dwelling. In determining whether a product is a
300 | consumer product, doubtful cases shall be resolved in favor of
301 | coverage. For a particular product received by a particular user,
302 | "normally used" refers to a typical or common use of that class of
303 | product, regardless of the status of the particular user or of the way
304 | in which the particular user actually uses, or expects or is expected
305 | to use, the product. A product is a consumer product regardless of
306 | whether the product has substantial commercial, industrial or
307 | non-consumer uses, unless such uses represent the only significant
308 | mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to
312 | install and execute modified versions of a covered work in that User
313 | Product from a modified version of its Corresponding Source. The
314 | information must suffice to ensure that the continued functioning of
315 | the modified object code is in no case prevented or interfered with
316 | solely because modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or
331 | updates for a work that has been modified or installed by the
332 | recipient, or for the User Product in which it has been modified or
333 | installed. Access to a network may be denied when the modification
334 | itself materially and adversely affects the operation of the network
335 | or violates the rules and protocols for communication across the
336 | network.
337 |
338 | Corresponding Source conveyed, and Installation Information provided,
339 | in accord with this section must be in a format that is publicly
340 | documented (and with an implementation available to the public in
341 | source code form), and must require no special password or key for
342 | unpacking, reading or copying.
343 |
344 | #### 7. Additional Terms.
345 |
346 | "Additional permissions" are terms that supplement the terms of this
347 | License by making exceptions from one or more of its conditions.
348 | Additional permissions that are applicable to the entire Program shall
349 | be treated as though they were included in this License, to the extent
350 | that they are valid under applicable law. If additional permissions
351 | apply only to part of the Program, that part may be used separately
352 | under those permissions, but the entire Program remains governed by
353 | this License without regard to the additional permissions.
354 |
355 | When you convey a copy of a covered work, you may at your option
356 | remove any additional permissions from that copy, or from any part of
357 | it. (Additional permissions may be written to require their own
358 | removal in certain cases when you modify the work.) You may place
359 | additional permissions on material, added by you to a covered work,
360 | for which you have or can give appropriate copyright permission.
361 |
362 | Notwithstanding any other provision of this License, for material you
363 | add to a covered work, you may (if authorized by the copyright holders
364 | of that material) supplement the terms of this License with terms:
365 |
366 | - a) Disclaiming warranty or limiting liability differently from the
367 | terms of sections 15 and 16 of this License; or
368 | - b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 | - c) Prohibiting misrepresentation of the origin of that material,
372 | or requiring that modified versions of such material be marked in
373 | reasonable ways as different from the original version; or
374 | - d) Limiting the use for publicity purposes of names of licensors
375 | or authors of the material; or
376 | - e) Declining to grant rights under trademark law for use of some
377 | trade names, trademarks, or service marks; or
378 | - f) Requiring indemnification of licensors and authors of that
379 | material by anyone who conveys the material (or modified versions
380 | of it) with contractual assumptions of liability to the recipient,
381 | for any liability that these contractual assumptions directly
382 | impose on those licensors and authors.
383 |
384 | All other non-permissive additional terms are considered "further
385 | restrictions" within the meaning of section 10. If the Program as you
386 | received it, or any part of it, contains a notice stating that it is
387 | governed by this License along with a term that is a further
388 | restriction, you may remove that term. If a license document contains
389 | a further restriction but permits relicensing or conveying under this
390 | License, you may add to a covered work material governed by the terms
391 | of that license document, provided that the further restriction does
392 | not survive such relicensing or conveying.
393 |
394 | If you add terms to a covered work in accord with this section, you
395 | must place, in the relevant source files, a statement of the
396 | additional terms that apply to those files, or a notice indicating
397 | where to find the applicable terms.
398 |
399 | Additional terms, permissive or non-permissive, may be stated in the
400 | form of a separately written license, or stated as exceptions; the
401 | above requirements apply either way.
402 |
403 | #### 8. Termination.
404 |
405 | You may not propagate or modify a covered work except as expressly
406 | provided under this License. Any attempt otherwise to propagate or
407 | modify it is void, and will automatically terminate your rights under
408 | this License (including any patent licenses granted under the third
409 | paragraph of section 11).
410 |
411 | However, if you cease all violation of this License, then your license
412 | from a particular copyright holder is reinstated (a) provisionally,
413 | unless and until the copyright holder explicitly and finally
414 | terminates your license, and (b) permanently, if the copyright holder
415 | fails to notify you of the violation by some reasonable means prior to
416 | 60 days after the cessation.
417 |
418 | Moreover, your license from a particular copyright holder is
419 | reinstated permanently if the copyright holder notifies you of the
420 | violation by some reasonable means, this is the first time you have
421 | received notice of violation of this License (for any work) from that
422 | copyright holder, and you cure the violation prior to 30 days after
423 | your receipt of the notice.
424 |
425 | Termination of your rights under this section does not terminate the
426 | licenses of parties who have received copies or rights from you under
427 | this License. If your rights have been terminated and not permanently
428 | reinstated, you do not qualify to receive new licenses for the same
429 | material under section 10.
430 |
431 | #### 9. Acceptance Not Required for Having Copies.
432 |
433 | You are not required to accept this License in order to receive or run
434 | a copy of the Program. Ancillary propagation of a covered work
435 | occurring solely as a consequence of using peer-to-peer transmission
436 | to receive a copy likewise does not require acceptance. However,
437 | nothing other than this License grants you permission to propagate or
438 | modify any covered work. These actions infringe copyright if you do
439 | not accept this License. Therefore, by modifying or propagating a
440 | covered work, you indicate your acceptance of this License to do so.
441 |
442 | #### 10. Automatic Licensing of Downstream Recipients.
443 |
444 | Each time you convey a covered work, the recipient automatically
445 | receives a license from the original licensors, to run, modify and
446 | propagate that work, subject to this License. You are not responsible
447 | for enforcing compliance by third parties with this License.
448 |
449 | An "entity transaction" is a transaction transferring control of an
450 | organization, or substantially all assets of one, or subdividing an
451 | organization, or merging organizations. If propagation of a covered
452 | work results from an entity transaction, each party to that
453 | transaction who receives a copy of the work also receives whatever
454 | licenses to the work the party's predecessor in interest had or could
455 | give under the previous paragraph, plus a right to possession of the
456 | Corresponding Source of the work from the predecessor in interest, if
457 | the predecessor has it or can get it with reasonable efforts.
458 |
459 | You may not impose any further restrictions on the exercise of the
460 | rights granted or affirmed under this License. For example, you may
461 | not impose a license fee, royalty, or other charge for exercise of
462 | rights granted under this License, and you may not initiate litigation
463 | (including a cross-claim or counterclaim in a lawsuit) alleging that
464 | any patent claim is infringed by making, using, selling, offering for
465 | sale, or importing the Program or any portion of it.
466 |
467 | #### 11. Patents.
468 |
469 | A "contributor" is a copyright holder who authorizes use under this
470 | License of the Program or a work on which the Program is based. The
471 | work thus licensed is called the contributor's "contributor version".
472 |
473 | A contributor's "essential patent claims" are all patent claims owned
474 | or controlled by the contributor, whether already acquired or
475 | hereafter acquired, that would be infringed by some manner, permitted
476 | by this License, of making, using, or selling its contributor version,
477 | but do not include claims that would be infringed only as a
478 | consequence of further modification of the contributor version. For
479 | purposes of this definition, "control" includes the right to grant
480 | patent sublicenses in a manner consistent with the requirements of
481 | this License.
482 |
483 | Each contributor grants you a non-exclusive, worldwide, royalty-free
484 | patent license under the contributor's essential patent claims, to
485 | make, use, sell, offer for sale, import and otherwise run, modify and
486 | propagate the contents of its contributor version.
487 |
488 | In the following three paragraphs, a "patent license" is any express
489 | agreement or commitment, however denominated, not to enforce a patent
490 | (such as an express permission to practice a patent or covenant not to
491 | sue for patent infringement). To "grant" such a patent license to a
492 | party means to make such an agreement or commitment not to enforce a
493 | patent against the party.
494 |
495 | If you convey a covered work, knowingly relying on a patent license,
496 | and the Corresponding Source of the work is not available for anyone
497 | to copy, free of charge and under the terms of this License, through a
498 | publicly available network server or other readily accessible means,
499 | then you must either (1) cause the Corresponding Source to be so
500 | available, or (2) arrange to deprive yourself of the benefit of the
501 | patent license for this particular work, or (3) arrange, in a manner
502 | consistent with the requirements of this License, to extend the patent
503 | license to downstream recipients. "Knowingly relying" means you have
504 | actual knowledge that, but for the patent license, your conveying the
505 | covered work in a country, or your recipient's use of the covered work
506 | in a country, would infringe one or more identifiable patents in that
507 | country that you have reason to believe are valid.
508 |
509 | If, pursuant to or in connection with a single transaction or
510 | arrangement, you convey, or propagate by procuring conveyance of, a
511 | covered work, and grant a patent license to some of the parties
512 | receiving the covered work authorizing them to use, propagate, modify
513 | or convey a specific copy of the covered work, then the patent license
514 | you grant is automatically extended to all recipients of the covered
515 | work and works based on it.
516 |
517 | A patent license is "discriminatory" if it does not include within the
518 | scope of its coverage, prohibits the exercise of, or is conditioned on
519 | the non-exercise of one or more of the rights that are specifically
520 | granted under this License. You may not convey a covered work if you
521 | are a party to an arrangement with a third party that is in the
522 | business of distributing software, under which you make payment to the
523 | third party based on the extent of your activity of conveying the
524 | work, and under which the third party grants, to any of the parties
525 | who would receive the covered work from you, a discriminatory patent
526 | license (a) in connection with copies of the covered work conveyed by
527 | you (or copies made from those copies), or (b) primarily for and in
528 | connection with specific products or compilations that contain the
529 | covered work, unless you entered into that arrangement, or that patent
530 | license was granted, prior to 28 March 2007.
531 |
532 | Nothing in this License shall be construed as excluding or limiting
533 | any implied license or other defenses to infringement that may
534 | otherwise be available to you under applicable patent law.
535 |
536 | #### 12. No Surrender of Others' Freedom.
537 |
538 | If conditions are imposed on you (whether by court order, agreement or
539 | otherwise) that contradict the conditions of this License, they do not
540 | excuse you from the conditions of this License. If you cannot convey a
541 | covered work so as to satisfy simultaneously your obligations under
542 | this License and any other pertinent obligations, then as a
543 | consequence you may not convey it at all. For example, if you agree to
544 | terms that obligate you to collect a royalty for further conveying
545 | from those to whom you convey the Program, the only way you could
546 | satisfy both those terms and this License would be to refrain entirely
547 | from conveying the Program.
548 |
549 | #### 13. Use with the GNU Affero General Public License.
550 |
551 | Notwithstanding any other provision of this License, you have
552 | permission to link or combine any covered work with a work licensed
553 | under version 3 of the GNU Affero General Public License into a single
554 | combined work, and to convey the resulting work. The terms of this
555 | License will continue to apply to the part which is the covered work,
556 | but the special requirements of the GNU Affero General Public License,
557 | section 13, concerning interaction through a network will apply to the
558 | combination as such.
559 |
560 | #### 14. Revised Versions of this License.
561 |
562 | The Free Software Foundation may publish revised and/or new versions
563 | of the GNU General Public License from time to time. Such new versions
564 | will be similar in spirit to the present version, but may differ in
565 | detail to address new problems or concerns.
566 |
567 | Each version is given a distinguishing version number. If the Program
568 | specifies that a certain numbered version of the GNU General Public
569 | License "or any later version" applies to it, you have the option of
570 | following the terms and conditions either of that numbered version or
571 | of any later version published by the Free Software Foundation. If the
572 | Program does not specify a version number of the GNU General Public
573 | License, you may choose any version ever published by the Free
574 | Software Foundation.
575 |
576 | If the Program specifies that a proxy can decide which future versions
577 | of the GNU General Public License can be used, that proxy's public
578 | statement of acceptance of a version permanently authorizes you to
579 | choose that version for the Program.
580 |
581 | Later license versions may give you additional or different
582 | permissions. However, no additional obligations are imposed on any
583 | author or copyright holder as a result of your choosing to follow a
584 | later version.
585 |
586 | #### 15. Disclaimer of Warranty.
587 |
588 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
589 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
590 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
591 | WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
592 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
593 | A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
594 | PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
595 | DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
596 | CORRECTION.
597 |
598 | #### 16. Limitation of Liability.
599 |
600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
602 | CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
603 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
604 | ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
605 | NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
606 | LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
607 | TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
608 | PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
609 |
610 | #### 17. Interpretation of Sections 15 and 16.
611 |
612 | If the disclaimer of warranty and limitation of liability provided
613 | above cannot be given local legal effect according to their terms,
614 | reviewing courts shall apply local law that most closely approximates
615 | an absolute waiver of all civil liability in connection with the
616 | Program, unless a warranty or assumption of liability accompanies a
617 | copy of the Program in return for a fee.
618 |
619 | END OF TERMS AND CONDITIONS
620 |
621 | ### How to Apply These Terms to Your New Programs
622 |
623 | If you develop a new program, and you want it to be of the greatest
624 | possible use to the public, the best way to achieve this is to make it
625 | free software which everyone can redistribute and change under these
626 | terms.
627 |
628 | To do so, attach the following notices to the program. It is safest to
629 | attach them to the start of each source file to most effectively state
630 | the exclusion of warranty; and each file should have at least the
631 | "copyright" line and a pointer to where the full notice is found.
632 |
633 |
634 | Copyright (C)
635 |
636 | This program is free software: you can redistribute it and/or modify
637 | it under the terms of the GNU General Public License as published by
638 | the Free Software Foundation, either version 3 of the License, or
639 | (at your option) any later version.
640 |
641 | This program is distributed in the hope that it will be useful,
642 | but WITHOUT ANY WARRANTY; without even the implied warranty of
643 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
644 | GNU General Public License for more details.
645 |
646 | You should have received a copy of the GNU General Public License
647 | along with this program. If not, see .
648 |
649 | Also add information on how to contact you by electronic and paper
650 | mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands \`show w' and \`show c' should show the
661 | appropriate parts of the General Public License. Of course, your
662 | program's commands might be different; for a GUI interface, you would
663 | use an "about box".
664 |
665 | You should also get your employer (if you work as a programmer) or
666 | school, if any, to sign a "copyright disclaimer" for the program, if
667 | necessary. For more information on this, and how to apply and follow
668 | the GNU GPL, see .
669 |
670 | The GNU General Public License does not permit incorporating your
671 | program into proprietary programs. If your program is a subroutine
672 | library, you may consider it more useful to permit linking proprietary
673 | applications with the library. If this is what you want to do, use the
674 | GNU Lesser General Public License instead of this License. But first,
675 | please read .
676 |
--------------------------------------------------------------------------------