-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3186714
Showing
17 changed files
with
1,158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.20' | ||
- name: Build | ||
run: go build ./... | ||
- name: Test | ||
run: go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: stable | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Binaries | ||
*.exe | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Go tool output | ||
*.out | ||
|
||
# Temporary and test files | ||
*.tmp | ||
*.temp | ||
*.test | ||
*.coverprofile | ||
*.coverage | ||
|
||
# IDE and editor files | ||
.vscode/ | ||
.idea/ | ||
*.swp | ||
*~ | ||
|
||
# macOS files | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
._* | ||
|
||
# Logs and environment files | ||
*.log | ||
.env | ||
.env.* | ||
|
||
# Go dependencies and build directories | ||
vendor/ | ||
bin/ | ||
dist/ | ||
go.sum | ||
|
||
# vhs file | ||
*.tape |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
before: | ||
hooks: | ||
- go mod tidy | ||
|
||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
ignore: | ||
- goos: windows | ||
goarch: arm64 | ||
main: ./cmd/keepalive | ||
ldflags: | ||
- -s -w -X main.version={{.Version}} | ||
mod_timestamp: '{{ .CommitTimestamp }}' | ||
|
||
archives: | ||
- format: tar.gz | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- title .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
{{- if .Arm }}v{{ .Arm }}{{ end }} | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
- '^ci:' | ||
- '^chore:' | ||
|
||
release: | ||
github: | ||
owner: stigoleg | ||
name: keep-alive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# Keep-Alive | ||
|
||
A lightweight, cross-platform utility to prevent your system from going to sleep. Perfect for maintaining active connections, downloads, or any process that requires your system to stay awake. | ||
|
||
[](https://github.com/stigoleg/keep-alive/releases/latest) | ||
[](https://goreportcard.com/report/github.com/stigoleg/keep-alive) | ||
[](https://opensource.org/licenses/MIT) | ||
|
||
 | ||
|
||
## Features | ||
|
||
|
||
- 🔄 Configurable keep-alive duration | ||
- 💻 Cross-platform support (macOS, Windows, Linux) | ||
- ⚡ Lightweight and efficient | ||
- 🎯 Simple and intuitive to use | ||
- 🛠 Zero configuration required | ||
|
||
## Installation | ||
|
||
Download the latest binary for your platform from the [GitHub releases page](https://github.com/stigoleg/keep-alive/releases/latest). | ||
|
||
### macOS and Linux | ||
|
||
1. Download the archive for your platform: | ||
```bash | ||
# For macOS: | ||
curl -LO https://github.com/stigoleg/keep-alive/releases/latest/download/keep-alive_Darwin_x86_64.tar.gz | ||
|
||
# For Linux: | ||
curl -LO https://github.com/stigoleg/keep-alive/releases/latest/download/keep-alive_Linux_x86_64.tar.gz | ||
``` | ||
|
||
2. Extract the archive: | ||
```bash | ||
tar xzf keep-alive_*_x86_64.tar.gz | ||
``` | ||
|
||
3. Move the binary to a location in your PATH: | ||
```bash | ||
sudo mv keepalive /usr/local/bin/ | ||
``` | ||
|
||
### Windows | ||
|
||
1. Download the Windows archive from the [releases page](https://github.com/stigoleg/keep-alive/releases/latest) | ||
2. Extract the archive | ||
3. Move `keepalive.exe` to your desired location | ||
4. (Optional) Add the location to your PATH environment variable | ||
|
||
## Usage | ||
|
||
1. Start the application: | ||
```bash | ||
keepalive | ||
``` | ||
|
||
2. Use arrow keys (↑/↓) or j/k to navigate the menu | ||
3. Press Enter to select an option | ||
4. When entering minutes, use numbers only (e.g., "150" for 2.5 hours) | ||
5. Press q or Esc to quit | ||
|
||
## How It Works | ||
|
||
Keep-Alive uses platform-specific APIs to prevent your system from entering sleep mode: | ||
|
||
- **macOS**: Uses the `caffeinate` command to prevent system and display sleep | ||
- **Windows**: Uses SetThreadExecutionState to prevent system sleep | ||
- **Linux**: Uses systemd-inhibit to prevent the system from going idle/sleep | ||
|
||
The application provides three main options: | ||
1. Keep system awake indefinitely | ||
2. Keep system awake for X minutes (enter the number of minutes) | ||
3. Quit the application | ||
|
||
When running with a timer, the application shows a countdown of the remaining time. You can stop the keep-alive at any time by pressing Enter to return to the menu or q/Esc to quit the application. | ||
|
||
## Dependencies | ||
|
||
### Runtime Dependencies | ||
|
||
- **Linux**: | ||
- systemd (recommended) or X11 | ||
- A terminal that supports TUI applications | ||
|
||
### Build Dependencies | ||
|
||
- Go 1.21 or later | ||
|
||
## Building from Source | ||
|
||
1. Clone the repository: | ||
```bash | ||
git clone https://github.com/stigoleg/keep-alive.git | ||
cd keep-alive | ||
``` | ||
|
||
2. Build the binary: | ||
```bash | ||
go build -o keepalive ./cmd/keepalive | ||
``` | ||
|
||
|
||
|
||
## Contributing | ||
|
||
Contributions are welcome! Please feel free to submit a Pull Request. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License. | ||
|
||
## Acknowledgments | ||
|
||
- [Bubble Tea](https://github.com/charmbracelet/bubbletea) - The TUI framework | ||
- [Lipgloss](https://github.com/charmbracelet/lipgloss) - Style definitions for terminal applications |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
"keepalive/internal/ui" | ||
|
||
tea "github.com/charmbracelet/bubbletea" | ||
) | ||
|
||
func main() { | ||
f, err := tea.LogToFile("debug.log", "debug") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
defer f.Close() | ||
|
||
p := tea.NewProgram( | ||
ui.InitialModel(), | ||
tea.WithAltScreen(), | ||
tea.WithInput(os.Stdin), | ||
tea.WithOutput(os.Stdout), | ||
) | ||
|
||
if _, err := p.Run(); err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module keepalive | ||
|
||
go 1.20 | ||
|
||
require ( | ||
github.com/charmbracelet/bubbletea v1.2.4 | ||
github.com/charmbracelet/lipgloss v1.0.0 | ||
golang.org/x/sys v0.28.0 | ||
) | ||
|
||
require ( | ||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect | ||
github.com/charmbracelet/x/ansi v0.4.5 // indirect | ||
github.com/charmbracelet/x/term v0.2.1 // indirect | ||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect | ||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/mattn/go-localereader v0.0.1 // indirect | ||
github.com/mattn/go-runewidth v0.0.15 // indirect | ||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect | ||
github.com/muesli/cancelreader v0.2.2 // indirect | ||
github.com/muesli/termenv v0.15.2 // indirect | ||
github.com/rivo/uniseg v0.4.7 // indirect | ||
golang.org/x/sync v0.9.0 // indirect | ||
golang.org/x/text v0.3.8 // indirect | ||
) |
Oops, something went wrong.