-
Notifications
You must be signed in to change notification settings - Fork 7
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
Showing
4 changed files
with
87 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,18 @@ | ||
#! /bin/bash | ||
|
||
# trap 'rm /tmp/running-jobs' SIGINT | ||
|
||
echo "$(date +%s) $1" > /tmp/running-jobs | ||
sh -c "$1 > /tmp/jobs.log 2>&1" | ||
STATUS=$? | ||
|
||
echo "$(date +%s) $1 $STATUS" > /tmp/finished-jobs | ||
rm /tmp/running-jobs || true | ||
|
||
echo | ||
|
||
case $STATUS in | ||
0) notify-send "Job '$(basename ${1})' is done." ;; | ||
*) notify-send "Job '$(basename ${1})' is failed." ;; | ||
esac | ||
|
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,36 @@ | ||
#! /bin/bash | ||
|
||
OUTDATED_SEC=300 | ||
RUNNING_LOG=/tmp/running-jobs | ||
FINISHED_LOG=/tmp/finished-jobs | ||
|
||
now=$(date +%s) | ||
|
||
if test -f "$RUNNING_LOG"; then | ||
CONTENT=$(cat $RUNNING_LOG) | ||
TS=$(echo $CONTENT| awk '{print $1}') | ||
JOB=$(echo $CONTENT| awk '{print $2}') | ||
RUNNING_SEC=$(($now-$TS)) | ||
JOB_NAME=$(basename $JOB) | ||
echo "[RUNNING: ${RUNNING_SEC}s] ${JOB_NAME}" | ||
exit 0; | ||
fi | ||
|
||
if test -f "$FINISHED_LOG"; then | ||
CONTENT=$(cat $FINISHED_LOG) | ||
TS=$(echo $CONTENT| awk '{print $1}') | ||
JOB=$(echo $CONTENT| awk '{print $2}') | ||
STATUS=$(echo $CONTENT| awk '{print $3}') | ||
|
||
AGO_SEC=$(($now-$TS)) | ||
JOB_NAME=$(basename $JOB) | ||
|
||
# print nothing if outdated | ||
(( $OUTDATED_SEC<($now-$TS) )) && exit 0 | ||
|
||
case $STATUS in | ||
0) echo "[FINISHED: ${AGO_SEC}s ago] ${JOB_NAME}" ;; | ||
*) echo "[FAILED: ${AGO_SEC}s] ${JOB_NAME}" ;; | ||
esac | ||
|
||
fi |
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,12 @@ | ||
#! /usr/bin/zsh | ||
source ~/.zshrc | ||
|
||
|
||
COLLECTION_ID=$(zenity --entry --title="Download Unsplash Collection" --text="Enter collection id:") | ||
|
||
if [ -z "${COLLECTION_ID}" ]; then | ||
zenity --info --text="No collection id specified" | ||
exit 1 | ||
fi | ||
|
||
unsplash download -d ~/Pictures/Wallpapers --token $UNSPLASH_TOKEN -H --min-width 3840 --min-height 2160 -c "${COLLECTION_ID}" |
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 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import subprocess | ||
|
||
if __name__ == '__main__': | ||
|
||
|
||
jobs = subprocess.run(['ls', '/home/anton/.bin/jobs'], encoding='utf-8', | ||
capture_output=True).stdout.split('\n') | ||
|
||
title = 'wofi-jobs' | ||
rofi_command = 'wofi -dmenu -i -p {}'.format(title) | ||
rofi_input = '\n'.join(job for job in jobs) | ||
cp = subprocess.run(rofi_command.split(), input=rofi_input, | ||
encoding='utf-8', capture_output=True) | ||
|
||
if cp.returncode == 0: | ||
file = cp.stdout.strip() | ||
xdg_command = ["/home/anton/.bin/job-run", f"/home/anton/.bin/jobs/{file}"] | ||
subprocess.run(xdg_command, | ||
encoding='utf-8', capture_output=True) |