-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from dirtyhenry/small-updates
feat: add my own hooks
- Loading branch information
Showing
8 changed files
with
95 additions
and
6 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
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,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Check if exactly 4 arguments are provided | ||
if [ "$#" -ne 4 ]; then | ||
echo "Usage: $0 arg1 arg2 arg3 arg4" | ||
exit 1 | ||
fi | ||
|
||
# This would stop focus. | ||
# /usr/bin/open focus://unfocus | ||
|
||
# # Writing to SQLite databse | ||
DATABASE="/Users/mick/Desktop/personal-cms.sqlite" | ||
TABLE="pomodoros" | ||
|
||
# Create the table if it doesn't exist | ||
sqlite3 "$DATABASE" <<EOF | ||
CREATE TABLE IF NOT EXISTS $TABLE ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
start TEXT NOT NULL, | ||
end TEXT NOT NULL, | ||
message TEXT | ||
); | ||
EOF | ||
|
||
# Insert the 4 arguments into the table | ||
sqlite3 "$DATABASE" <<EOF | ||
INSERT INTO $TABLE (start, end, message) | ||
VALUES ('$1', '$2', '$4'); | ||
EOF | ||
|
||
osascript -l JavaScript /Users/mick/.pomodoro-cli/notify.js "🍅 Pomodoro" "Completed" "$4" "Blow" | ||
|
||
# Turn off the display after a 5 seconds delay. | ||
sleep 5 | ||
/usr/bin/pmset displaysleepnow |
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,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Check if exactly 4 arguments are provided | ||
if [ "$#" -ne 4 ]; then | ||
echo "Usage: $0 arg1 arg2 arg3 arg4" | ||
exit 1 | ||
fi | ||
|
||
afplay ~/Documents/Private/Pop\ Culture/be-curious-not-judgemental.mp3 |
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 @@ | ||
// Import standard library | ||
ObjC.import("stdlib"); | ||
|
||
// Convert arguments from Objective-C array to JavaScript array | ||
const args = $.NSProcessInfo.processInfo.arguments; | ||
const argc = $.NSProcessInfo.processInfo.arguments.count; | ||
var arguments = []; | ||
for (var i = 4; i < argc; i++) { | ||
// Starting from 4 to skip script name and AppleScript overhead arguments | ||
arguments.push(ObjC.unwrap(args.objectAtIndex(i))); | ||
} | ||
|
||
const displayNotification = (title, subtitle, message, soundName) => { | ||
const app = Application.currentApplication(); | ||
app.includeStandardAdditions = true; | ||
|
||
// 📜 Checkout out sound names in /System/Library/Sounds/ | ||
app.displayNotification(message, { | ||
withTitle: title, | ||
subtitle: subtitle, | ||
soundName: soundName, | ||
}); | ||
}; | ||
|
||
// Use arguments in the function | ||
if (arguments.length >= 4) { | ||
displayNotification(arguments[0], arguments[1], arguments[2], arguments[3]); | ||
} else { | ||
console.log( | ||
"Usage: osascript myScript.js <title> <subtitle> <message> <soundName>" | ||
); | ||
} |
File renamed without changes.
File renamed without changes.
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
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