Commit c23a9ca5 authored by Jonas Neugebauer's avatar Jonas Neugebauer

Added some new scripts

parent 81c53769
(*
description: >
Adds a new task to Things. (For use with Alfredapp:
alfredapp.com and Arimail: airmail.com)
name: Add new task from selected mail to 2Do
apps: 2Do,Mail
description: >
Creates a new task in 2Dos default list with a link to the selected
message in Mail.
parameters:
TODO_TAGS: "Tags for the newly created task, **default**: `\"Mail\"`"
TASK_PREFIX: "Prefix for the mail subject to use in the tasks title, **default**: `\"Read: \"`"
INBOX_NAME: "Name of the list to add the task to, **default**: `\"Inbox\"`"
compile: true
*)
property TODO_TAGS : "Mail"
property TASK_PREFIX : "Lesen: "
property INBOX_NAME : "Eingang"
on alfred_script(q)
tell application "Mail"
set theMail to first item of (get selection)
set theSubject to subject of theMail
set theMessage to "message://<" & (message id of theMail as rich text) & ">"
set theSender to sender of theMail
set theContent to content of theMail
end tell
tell application "Safari"
set theURL to "twodo://x-callback-url/add?task=" & TASK_PREFIX & theSubject & "&action=url:" & theMessage & "&note=" & theContent & "&tags=" & TODO_TAGS
open location theURL
-- delay 1
close current tab of window 1
end tell
return theURL
end alfred_script
#!/usr/bin/env bash
# name: Copy files
# apps: Alfred
# description: "Copies the passed in files to `folder`"
# parameters:
# folder: "The folder the files will be copied to, **default**: `~/Downloads`"
folder="~/Downloads"
IFS=" "
files="{query}"
for file in $files
do cp "$file" "$folder"
done
#!/usr/bin/env bash
# name: Move files
# apps: Alfred
# description: "Moves the passed in files to `folder`"
# parameters:
# folder: "The folder the files will be moved to, **default**: `~/Downloads`"
folder="~/Downloads"
IFS=" "
files="{query}"
for file in $files
do mv "$file" "$folder"
done
# name: Add alarms to ics
# apps: Caffeine, Alfred
# description: Adds alarms to all events in an .ics file
# parameters:
# _TRIGGERS: "A list of times to trigger alarms at, **default**: `['-PT5H']`"
# _ACTION: "The action for the alarms, **default**: `DISPLAY`"
# _SUFFIX "A suffix to append to the filename, if no out file is defined, **default**: `'-w-alarms'`"
# compile: false
import sys
import os
import icalendar
from datetime import datetime
# Configuration
_TRIGGERS = ['-PT5H']
_ACTION = 'DISPLAY'
_SUFFIX = '-w-alarms'
if len(sys.argv) < 2:
sys.exit("Usage: python addalarms.py input.ics output.ics")
if sys.argv[1].endswith('.ics'):
with open(sys.argv[1]) as ical_file:
cal = icalendar.cal.Component.from_ical(ical_file.read())
n = 0
a = 0
for sub in cal.subcomponents:
for trigger in _TRIGGERS:
alarm = icalendar.cal.Alarm()
alarm['trigger'] = trigger
alarm['action'] = _ACTION
alarm['description'] = sub['summary']
sub.add_component(alarm)
a += 1
n += 1
if len(sys.argv) >= 3:
with open(sys.argv[2], 'wb') as ical_result:
ical_result.write(cal.to_ical())
else:
filename, ext = os.path.splitext(sys.argv[1])
with open("%s%s.ics" % (filename, _SUFFIX), 'wb') as ical_result:
ical_result.write(cal.to_ical())
print('done: added %s alarms to %s events' % (a, n))
#!/usr/bin/env bash
base=$(basename "$1")
name=${base%.*}
spctl --add --label "$name" "$1"
open "$1"
-- tag items with album:albumname
tell application "Photos"
set theAlbums to albums
repeat with aAlbum in theAlbums
--log "Tagging items in album " & (name of aAlbum as text)
tell aAlbum
set albumTag to "album:" & (name of aAlbum as text)
set theItems to media items
repeat with aItem in theItems
set theKeywords to (keywords of aItem)
if theKeywords is missing value then
set keywords of aItem to albumTag
else if theKeywords does not contain albumTag then
set the end of theKeywords to albumTag
set keywords of aItem to theKeywords
end if
end repeat
end tell
end repeat
end tell
\ No newline at end of file
(*
name: Create markdown list of current Safari session
apps: TextExpander, Safari
description: |
Creates a markdown document from the URLs currently open in
Safaris frontmost window.
```
# Safari links from 2016-02-02 10:01:02
## Tabs
- [Quelltext der Seite Vorlage:OptionalProperty Informatik-Box](http://informatik-box.de/index.php?title=Vorlage:OptionalProperty&action=edit)
- [Kategorie:BibTeX Attribut Informatik-Box](http://informatik-box.de/wiki/Kategorie:BibTeX_Attribut)
- [Nicht kategorisierte Seiten Informatik-Box](http://informatik-box.de/wiki/Spezial:Nicht_kategorisierte_Seiten)
- [Nicht kategorisierte Vorlagen Informatik-Box](http://informatik-box.de/wiki/Spezial:Nicht_kategorisierte_Vorlagen)
- [InfoBox:Urheberrechte Informatik-Box](http://informatik-box.de/wiki/InfoBox:Urheberrechte)
- [Vorlage:Rating Informatik-Box](http://informatik-box.de/wiki/Vorlage:Rating)
- [Anmelden Informatik-Box](http://informatik-box.de/index.php?title=Spezial:Anmelden&returnto=Spezial%3ABeobachtungsliste&returntoquery=&warning=watchlistanontext)
- [Category:Developer documentation semantic-mediawiki.org](https://www.semantic-mediawiki.org/wiki/Category:Developer_documentation)
- [EduTech Wiki](http://edutechwiki.unige.ch/en/Main_Page)
- [Extension:EditImage - MediaWiki](https://www.mediawiki.org/wiki/Extension:EditImage)
```
parameters:
PINNED: "number of pinned tabs to ignore, **default**: `4`"
compile: false
*)
property PINNED : 4
property NL : "
"
tell application "Safari"
-- set theURLs to URL of tabs of first window
set theTabs to tabs of first window
set theNote to "# Safari links from " & (current date) as text
set theNote to theNote & NL & NL & "## Tabs" & NL
set i to 0
repeat with aTab in theTabs
if i PINNED then
try
set aURL to URL of aTab
set aTitle to name of aTab
set theNote to theNote & NL & "- [" & aTitle & "](" & aURL & ")"
end try
end if
set i to i + 1
end repeat
return theNote
end tell
(*
Adds a new task to Things. (For use with Alfredapp: alfredapp.com and Arimail: airmail.com)
*)
property TODO_TAGS : "Mail"
property TASK_PREFIX : "Act on: "
on alfred_script(q)
tell application "Mail"
set theMail to first item of (get selection)
set theSubject to subject of theMail
set theMessage to "message://<" & (message id of theMail as rich text) & ">"
set theSender to sender of theMail
set theContent to content of theMail
end tell
tell application "Safari"
set theURL to "twodo://x-callback-url/add?task=" & TASK_PREFIX & theSubject & "&action=url:" & theMessage & "&note=" & theContent & "&tags=" & TODO_TAGS
open location theURL
-- delay 1
close current tab of window 1
end tell
return TASK_PREFIX & theSubject
end alfred_script
(*
name: Reindex tags of selected songs in iTunes
apps: iTunes
description: >
Reindex the songs currently selected in iTunes. For easy
use put into `~/Library/iTunes/Scripts/`.
parameters:
compile: true
*)
tell application "iTunes"
set aList to selection
set numberOfItems to count of aList
display notification "Refreshing " & numberOfItems & " items. This may take a while.." with title "iTunes refresh Selection"
refresh selection
display notification "Done refreshing " & numberOfItems & " items." with title "iTunes refresh Selection"
end tell
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment