-
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 57001eb
Showing
101 changed files
with
6,548 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,2 @@ | ||
[run] | ||
omit = *_test.py,__main__.py,__init__.py |
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,34 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- "master" | ||
|
||
env: | ||
PYTHON_VERSION: 3.11.3 | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: install poetry | ||
run: pip3 install poetry | ||
|
||
- name: install deps | ||
run: poetry install | ||
|
||
|
||
- name: test | ||
run: poetry run pytest --cache-clear | ||
|
||
- name: publish | ||
run: | | ||
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN}} | ||
poetry build | ||
poetry publish |
Empty file.
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,4 @@ | ||
__pycache__ | ||
.coverage | ||
htmlcov/ | ||
dist/ |
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,7 @@ | ||
Copyright 2024 Anton Shuvalov | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,237 @@ | ||
# Zapusk | ||
|
||
![Zapusk ScreenShot](.imgs/zapusk.png) | ||
|
||
Zapusk is a job runner for desktop environments. It helps you manage background tasks with features like pre-configured job execution, background shell commands, scheduling with cron-like syntax, log tailing, and notifications. It also provides detailed JSON output for easy data manipulation and analysis. | ||
|
||
## Key Features | ||
|
||
- **Preconfigured Jobs:** Run jobs defined in your configuration files. | ||
- **Background Command Execution:** Run shell commands in the background with optional log tailing. | ||
- **Cron-like Scheduling:** Schedule tasks using flexible cron syntax. | ||
- **Log Tailing:** View logs in real-time. | ||
- **Job Management:** Cancel running jobs and check their statuses. | ||
- **Job Groups:** Share settings like callbacks and parallelism between jobs. | ||
- **Colored JSON Output:** Easily readable JSON output. | ||
- **Waybar Integration:** Display job statuses and notifications on Waybar. | ||
|
||
## Installation | ||
|
||
Install Zapusk using `pip`: | ||
|
||
```sh | ||
pip install zapusk | ||
``` | ||
|
||
## Usage | ||
|
||
Zapusk offers a command-line interface for managing and executing jobs. Here's a quick reference: | ||
|
||
```sh | ||
Usage: | ||
zapusk -h | --help | ||
zapusk --version | ||
zapusk run <job_config_id> [--colors|--no-colors] [--tail] | ||
zapusk exec <command> [--name=<name>] [--group=<group>] [--tail] [--schedule=<cron_expression>] [--colors|--no-colors] | ||
zapusk cancel <job_id> [--scheduled] [--colors|--no-colors] | ||
zapusk tail <job_id> | ||
zapusk list [--filter=<state>|--scheduled] [--colors|--no-colors] | ||
zapusk config_jobs [--colors|--no-colors] | ||
zapusk config_groups [--colors|--no-colors] | ||
zapusk waybar | ||
|
||
Options: | ||
-h --help Show this screen. | ||
--version Show version. | ||
--colors Enable colors. | ||
--no-colors Disable colors. | ||
--filter=<state> Filter jobs by status. | ||
-n --name=<name> Name for a command. | ||
-g --group=<group> Job group to run the command in. | ||
-t --tail Tail logfile immediately. | ||
|
||
Examples: | ||
|
||
# Run npm install in the background | ||
zapusk exec "npm i" | ||
|
||
# Run pytest and tail its log | ||
zapusk exec "pytest -v" -t | ||
|
||
# Schedule a command to run every minute | ||
zapusk exec "ping -c4 google.com" --schedule "*/1 * * * *" | ||
|
||
# Run a job defined in ~/.config/zapusk/config.yaml | ||
zapusk run youtube_dl | ||
|
||
# Cancel a job by its ID | ||
zapusk cancel 42 | ||
|
||
# See logs for a job by its ID | ||
zapusk tail 42 | ||
``` | ||
|
||
## Example Configuration | ||
|
||
Here is an example configuration file for Zapusk. It defines job groups and individual jobs, specifying commands, schedules, and notifications. | ||
|
||
```yaml | ||
# Port server starts on and client call to | ||
port: 9876 | ||
|
||
# Enable colored JSON output | ||
colors: True | ||
|
||
job_groups: | ||
- id: unsplash | ||
parallel: 1 | ||
- id: sleep | ||
parallel: 2 | ||
- id: cmd | ||
parallel: 10 | ||
on_finish: notify-send -a "zapusk" "Command Finished" "{job.name} has finished" --icon kitty | ||
on_fail: notify-send -a "zapusk" "Command Failed" "{job.name} has failed" --icon kitty | ||
- id: cronie | ||
parallel: 1 | ||
on_finish: notify-send -a "zapusk" "Scheduled Job Finished" "{job.name} has finished" --icon kitty | ||
on_fail: notify-send -a "zapusk" "Scheduled Job Failed" "{job.name} has failed" --icon kitty | ||
|
||
jobs: | ||
- name: Unsplash Download | ||
id: unsplash | ||
args_command: "zenity --entry --text 'Collection ID'" | ||
command: ~/.bin/jobs/unsplash_dl.sh | ||
|
||
- name: Sleep | ||
id: sleep | ||
group: sleep | ||
args_command: "zenity --entry --text 'Sleep Time'" | ||
command: sleep | ||
on_finish: notify-send -a "zapusk" "Job Finished" "{job.name} has finished" --icon kitty | ||
on_fail: notify-send -a "zapusk" "Job Failed" "{job.name} has failed" --icon kitty | ||
|
||
- name: Cronie | ||
id: cronie | ||
group: cronie | ||
schedule: "*/10 * * * *" | ||
command: sleep 2 | ||
``` | ||
## Advanced Usage | ||
### Running Preconfigured Jobs | ||
Run jobs defined in your configuration file using their `id`. | ||
|
||
```yaml | ||
# Job configuration in ~/.config/zapusk/config.yaml | ||
jobs: | ||
- name: Unsplash Download | ||
id: unsplash | ||
args_command: "zenity --entry --text 'Collection ID'" | ||
command: ~/.bin/jobs/unsplash_wallpaper_collection_download.sh | ||
on_finish: notify-send -a "Zapusk" "Wallpapers downloaded" --icon kitty | ||
on_fail: notify-send -a "Zapusk" "Wallpaper download failed" --icon kitty | ||
``` | ||
|
||
```sh | ||
# Run the `unsplash` job: | ||
zapusk run unsplash | ||
``` | ||
|
||
### Background Command Execution | ||
|
||
Run commands in the background with optional log tailing: | ||
|
||
```sh | ||
zapusk exec "npm i" -t | ||
``` | ||
|
||
### Scheduling Commands | ||
|
||
Schedule commands to run at specific intervals using cron syntax: | ||
|
||
```sh | ||
zapusk exec "ping -c4 google.com" --schedule "*/1 * * * *" | ||
``` | ||
|
||
Pre-configured jobs can also be scheduled: | ||
|
||
```yaml | ||
jobs: | ||
- name: Cronie | ||
id: cronie | ||
group: cronie | ||
schedule: "*/10 * * * *" | ||
command: sleep 2 | ||
``` | ||
### Managing Jobs | ||
Cancel a running or scheduled job by its ID: | ||
```sh | ||
zapusk cancel 42 | ||
``` | ||
|
||
Tail the logs of a running job by its ID: | ||
|
||
```sh | ||
zapusk tail 42 | ||
``` | ||
|
||
List all pending, running, and finished jobs: | ||
|
||
```sh | ||
zapusk list | ||
``` | ||
|
||
### Callbacks | ||
|
||
Use `on_finish` and `on_fail` callbacks for notifications. | ||
|
||
For job group callbacks: | ||
|
||
```yaml | ||
job_groups: | ||
- id: my_group | ||
parallel: 10 | ||
on_finish: notify-send -a "zapusk" "Command Finished" "{job.name} has finished" --icon kitty | ||
on_fail: notify-send -a "zapusk" "Command Failed" "{job.name} has failed" --icon kitty | ||
``` | ||
For individual job callbacks: | ||
```yaml | ||
jobs: | ||
- name: Sleep | ||
id: sleep | ||
group: sleep | ||
command: ~/.bin/jobs/sleep | ||
on_finish: notify-send -a "zapusk" "Job Finished" "{job.name} has finished" --icon kitty | ||
on_fail: notify-send -a "zapusk" "Job Failed" "{job.name} has failed" --icon kitty | ||
``` | ||
### Waybar Integration | ||
Zapusk integrates with Waybar to display job statuses and notifications directly on your desktop. | ||
```json | ||
// Example integration with wofi and jq | ||
"custom/zapusk": { | ||
"exec": "zapusk waybar", | ||
"on-click": "zapusk config_jobs --no-colors | jq -r \".[].id\" | wofi --dmenu | xargs -I{} zapusk run {}", | ||
"tooltip": true, | ||
"return-type": "json", | ||
"format": "{}", | ||
"interval": 1 | ||
} | ||
``` | ||
|
||
## Contribution | ||
|
||
We welcome contributions! If you find a bug or have an idea for improvement, please open an issue or submit a pull request on our GitHub repository. | ||
|
||
## License | ||
|
||
Zapusk is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information. |
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,27 @@ | ||
# Example configuration for | ||
port: 9876 | ||
|
||
job_groups: | ||
- id: default | ||
parallel: 10 | ||
- id: sequential | ||
parallel: 1 | ||
- id: parallel | ||
parallel: 2 | ||
|
||
|
||
jobs: | ||
- name: Sleep 10 Seconds | ||
id: sleep_10 | ||
command: sleep 10 | ||
|
||
- name: Sleep 30 Seconds | ||
group: parallel | ||
id: sleep_30 | ||
command: sleep 30 | ||
|
||
- name: Configurable Sleep | ||
id: sleep | ||
group: sequential | ||
args_command: "zenity --entry --text 'Sleep Time'" | ||
command: "sleep $1" |
Oops, something went wrong.