feat(bin): raycast helpers

Signed-off-by: Ismo Vuorinen <ismo@ivuorinen.net>
This commit is contained in:
2025-02-19 10:13:52 +02:00
parent ceb452aa68
commit aa85bb0c72
7 changed files with 260 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
#!/bin/bash
# Note: Lungo v2.0.4 required
# Install via Mac App Store: https://apps.apple.com/app/id1263070803
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Lungo: Activate
# @raycast.mode silent
# Optional parameters:
# @raycast.icon ./images/lungo.png
# @raycast.packageName Lungo
# Documentation:
# @raycast.author Lungo
# @raycast.authorURL https://sindresorhus.com/lungo
# @raycast.description Deactivate Lungo.
# @raycast.argument1 { "type": "text", "placeholder": "hours", "optional": true, "percentEncoded": true }
# @raycast.argument2 { "type": "text", "placeholder": "minutes", "optional": true, "percentEncoded": true }
open --background "lungo:activate?hours=$1&minutes=$2"

View File

@@ -0,0 +1,20 @@
#!/bin/bash
# Note: Lungo v2.0.4 required
# Install via Mac App Store: https://apps.apple.com/app/id1263070803
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Lungo: Deactivate
# @raycast.mode silent
# Optional parameters:
# @raycast.icon ./images/lungo.png
# @raycast.packageName Lungo
# Documentation:
# @raycast.author Lungo
# @raycast.authorURL https://sindresorhus.com/lungo
# @raycast.description Deactivate Lungo.
open --background lungo:deactivate

View File

@@ -0,0 +1,22 @@
#!/bin/bash
# Note: Lungo v2.0.4 required
# Install via Mac App Store: https://apps.apple.com/app/id1263070803
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Lungo: Toggle
# @raycast.mode silent
# Optional parameters:
# @raycast.icon ./images/lungo.png
# @raycast.packageName Lungo
# Documentation:
# @raycast.author Lungo
# @raycast.authorURL https://sindresorhus.com/lungo
# @raycast.description Toggle Lungo.
# @raycast.argument1 { "type": "text", "placeholder": "hours", "optional": true, "percentEncoded": true }
# @raycast.argument2 { "type": "text", "placeholder": "minutes", "optional": true, "percentEncoded": true }
open --background "lungo:toggle?hours=$1&minutes=$2"

View File

@@ -0,0 +1,100 @@
#!/usr/bin/env python3
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Convert Markdown to Telegram Format
# @raycast.mode silent
# Optional parameters:
# @raycast.icon 🔄
# @raycast.packageName Conversions
# @raycast.description Convert Markdown formatting to Telegram format, excluding processing inside code blocks or quotes
# Documentation:
# @raycast.author Maxim Borzov
# @raycast.authorURL https://github.com/borzov
import re
import subprocess
# Set environment variables and encoding
env_vars = {'LANG': 'en_US.UTF-8'}
encoding = 'utf-8'
def paste():
"""Read text from the clipboard."""
return subprocess.check_output('pbpaste', env=env_vars).decode(encoding)
def copy(text):
"""Write text to the clipboard."""
process = subprocess.Popen('pbcopy', env=env_vars, stdin=subprocess.PIPE)
process.communicate(text.encode(encoding))
def convert_markdown(text):
"""Convert Markdown formatting to Telegram format."""
lines = text.split('\n')
converted_lines = []
in_code_block = False
for line in lines:
# Check if the line is a code block delimiter
if line.startswith('```'):
in_code_block = not in_code_block
converted_lines.append(line)
continue
# Skip quotes and only format if not in a code block
if not in_code_block and not line.startswith('>'):
# Format headers with emojis and bold text
if line.startswith('# '):
line = f"⚫️ **{line[2:].strip()}**\n"
elif line.startswith('## '):
line = f"◾️ **{line[3:].strip()}**\n"
elif line.startswith('### '):
line = f"▪️ **{line[4:].strip()}**\n"
elif line.startswith('#### '):
line = f"🔹 **{line[5:].strip()}**\n"
elif line.startswith('##### '):
line = f"📌 **{line[6:].strip()}**\n"
elif line.startswith('###### '):
line = f"🔰 **{line[7:].strip()}**\n"
else:
# Format bold text
line = re.sub(r'(?<!\\)\*{2}(.*?)\*{2}', r'**\1**', line)
line = re.sub(r'(?<!\\)_{2}(.*?)_{2}', r'**\1**', line)
# Format italic text
line = re.sub(r'(?<!\\|\*)\*(?!\*)(.+?)(?<!\*)\*(?![\*_])', r'__\1__', line)
line = re.sub(r'(?<!\\|_)_(?!_)(.+?)(?<!_)_(?![\*_])', r'__\1__', line)
# Format strikethrough text
line = re.sub(r'(?<!\\)~{2}(.*?)~{2}', r'~~\1~~', line)
# Format spoilers
line = re.sub(r'(?<!\\)\|\|(.*?)\|\|', r'||\1||', line)
# Format underline text
line = re.sub(r'(?<!\\)-{2}(.*?)-{2}', r'--\1--', line)
# Format links
line = re.sub(r'(?<!\\)\[(.*?)\]\((.*?)\)', r'[\1](\2)', line)
# Format inline code
line = re.sub(r'(?<!\\)`(.*?)`', r'`\1`', line)
converted_lines.append(line)
# Add empty lines between paragraphs
result = []
for i in range(len(converted_lines)):
result.append(converted_lines[i])
if i < len(converted_lines) - 1:
cur = converted_lines[i].strip()
next = converted_lines[i+1].strip()
if cur and next and not cur.startswith(('*', '-', '```', '|', '>')) and not next.startswith(('*', '-', '```', '|', '>')):
result.append('')
return '\n'.join(result)
if __name__ == "__main__":
try:
markdown_text = paste()
converted_text = convert_markdown(markdown_text)
copy(converted_text)
print("✅ Markdown converted and copied to clipboard")
except Exception as e:
print(f"❌ Error during conversion: {str(e)}")

21
local/bin/raycast/sp.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Dependency: requires the 1password cli: https://developer.1password.com/docs/cli/
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Login password to clipboard
# @raycast.mode silent
# Optional parameters:
# @raycast.icon 🔐
# @raycast.packageName Password to clipboard
# @raycast.description Returns password from 1Password
# Documentation:
# @raycast.author Ismo Vuorinen
# @raycast.authorURL https://github.com/ivuorinen
set -euo pipefail
op read "op://Svea/3hzhctmvovbwlgulv7mgy25rf4/login-input" | pbcopy

View File

@@ -0,0 +1,26 @@
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Tidal: Toggle Play/Pause
# @raycast.mode silent
# @raycast.packagename Tidal
# Optional parameters
# @raycast.icon images/tidal-logo.png
# Documentation:
# @raycast.author Cebrail AKTAS
# @raycast.authorURL https://github.com/AktasC
# @raycast.description Play/Pause Tidal
tell application "System Events"
tell process "TIDAL"
click first menu item of menu "Playback" of menu bar 1
if name of first menu item of menu "Playback" of menu bar 1 is "Play" then
log "▶️"
else
log "⏸"
end if
end tell
end tell

View File

@@ -0,0 +1,49 @@
#!/usr/bin/swift
// Required parameters:
// @raycast.schemaVersion 1
// @raycast.title Zalgo Text
// @raycast.mode silent
// @raycast.author Adam Zethraeus
// @raycast.authorURL https://github.com/adam-zethraeus
// @raycast.packageName Conversions
// @raycast.icon 👹
// @raycast.argument1 { "type": "text", "placeholder": "Text to Z̶̶͚̯͗a̩̞͜͜l̫͕ͬͨ̿g͈̫͂ͤ͆͢o̠͚̞ͥ" }
// @raycast.argument2 { "type": "text", "optional": true, "placeholder": "Intensity=5" }
// Documentation:
// @raycast.description Converts text to z̫̫̐a̳ͩl̓͂̀ͅg͔̚o̷̦̣͢ t̳͆ḛ̊͟ẍ̮̝́t̵̔ͯ͝
import Cocoa
// zalgo function credit mattt @ https://gist.github.com/mattt/b46ab5027f1ee6ab1a45583a41240033
func zalgo(_ string: String, intensity: Int = 5) -> String {
let combiningDiacriticMarks = 0x0300...0x036f
let latinAlphabetUppercase = 0x0041...0x005a
let latinAlphabetLowercase = 0x0061...0x007a
var output: [UnicodeScalar] = []
for scalar in string.unicodeScalars {
output.append(scalar)
guard (latinAlphabetUppercase).contains(numericCast(scalar.value)) ||
(latinAlphabetLowercase).contains(numericCast(scalar.value))
else {
continue
}
for _ in 0...(Int.random(in: 1...intensity)) {
let randomScalarValue = Int.random(in: combiningDiacriticMarks)
output.append(Unicode.Scalar(randomScalarValue)!)
}
}
return String(String.UnicodeScalarView(output))
}
NSPasteboard.general.clearContents()
let text = CommandLine.arguments[1]
let intensityString = CommandLine.arguments[2]
let intensity = Int(intensityString) ?? 5
let zalgoText = zalgo(text, intensity: intensity)
NSPasteboard.general.setString(zalgoText, forType: .string)
print("\(zalgoText) copied to clipboard")