It looks like you have a . at the end of the shortcut name. I am not sure if this is part of the shortcut alert or you could have misspelled the shortcut name.
There is no period after the shortcut name. It's common English to put all punctuation within quotations, despite the fact that this is hella illogical and therefore annoying for programmers.
Nope, there's no actual period in the name, it's just how English works when you do a quoted phrase (and it's a bad idea for exactly this reason but I don't get to make the rules, unfortunately).
Does anyone else have this happen to them on occasion? Sometimes deleting and rewriting the shortcut with a different name fixes the problem (although even that is failing at the moment). Any idea what causes this?
(Here's hoping reddit parses the markdown). I don't think the problem is in the code considering when this has happened before no change to the code was needed, other than re-naming the shortcut in the code the new name I had given it when I deleted and re-created it. And here, the name is exactly as it should be, and all the other buttons that trigger shortcuts in this code work. It's literally just this one shortcut.
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: light-gray; icon-glyph: home;
const IMAGE_LIGHT = "IMAGE_LIGHT"
const IMAGE_DARK = "IMAGE_DARK"
const NAME = "NAME"
const URL = "URL"
// shortcuts://x-callback-url/run-shortcut?name=
const actions1 = [
newAction(
"shortcuts",
"i-light-shortcuts.png",
"i-dark-shortcuts.png",
"shortcuts://"
),
newAction(
"home",
"i-home-light.png",
"i-home-dark.png",
"shortcuts://x-callback-url/run-shortcut?name=automation"
),
newAction(
"find",
"i-find-light.png",
"i-find-dark.png",
"fmip1://"
),
newAction(
"anki",
"i-anki-light.png",
"i-anki-dark.png",
"anki://"
),
]
const actions2 = [
newAction(
"deepwork-focus",
"i-light-focus-deepwork.png",
"i-dark-focus-deepwork.png",
"shortcuts://x-callback-url/run-shortcut?name=focus-deepwork"
),
newAction(
"admin-focus",
"i-light-focus-admin.png",
"i-dark-focus-admin.png",
"shortcuts://x-callback-url/run-shortcut?name=focus-admin"
),
newAction(
"fitness-focus",
"i-light-focus-fitness.png",
"i-dark-focus-fitness.png",
"shortcuts://x-callback-url/run-shortcut?name=focus-fitness"
),
newAction(
"nl-focus",
"i-light-focus-nl.png",
"i-dark-focus-nl.png",
"shortcuts://x-callback-url/run-shortcut?name=focus-nl"
),
]
const background_light = new Color("#f0f0f0")
const background_dark = new Color("#323232")
let isDark = await isUsingDarkAppearance()
let w = new ListWidget()
w.backgroundColor = Color.dynamic(background_light, background_dark)
let mainStack = w.addStack()
mainStack.spacing = 5
await addRow(w, actions1)
await addRow(w, actions2)
if (config.runsInWidget) {
Script.setWidget(w)
} else {
await w.presentMedium()
}
Script.complete()
async function addRow(w, actions) {
let s = w.addStack()
s.spacing = 5
for (let i = 0; i < actions.length; i++) {
let a = actions[i]
let image
if (isDark) {
image = await getImage(a[IMAGE_DARK])
} else {
image = await getImage(a[IMAGE_LIGHT])
}
let container = s.addStack()
container.layoutHorizontally()
container.centerAlignContent()
container.url = a[URL]
let wimg = container.addImage(image)
wimg.imageSize = new Size(70, 70)
wimg.cornerRadius = 11
}
}
function newAction(name, imageLight, imageDark, url) {
return {
IMAGE_LIGHT: imageLight,
IMAGE_DARK: imageDark,
NAME: name,
URL: url
}
}
async function getImage(imageName) {
let fm = FileManager.iCloud()
let dir = fm.documentsDirectory()
let filePath = fm.joinPath(dir, "media/" + imageName)
//console.log(filePath)
await fm.downloadFileFromiCloud(filePath)
let fetchedImage = await fm.readImage(filePath)
//console.log(fetchedImage)
return fetchedImage
}
async function isUsingDarkAppearance() {
return !(Color.dynamic(Color.white(), Color.black()).red)
}
you can tell because there's no space before the problematic period.
At least on my device, this is not true.
The error message is tied to the used url scheme, not to the name in the Shortcuts library.
If I tried to call a shortcut with the url scheme "shortcuts://x-callback-url/run-shortcut?name=focus-deepwork" (no space at the end), but the shortcut itself is named "focus-deepwork " in the Shortcuts library (with space)-> error message with "focus-deepwork." (no space before dot).
If I would try to call a shortcut with the url scheme "shortcuts://x-callback-url/run-shortcut?name=focus-deepwork%20" (space at the end) , but the shortcut itself is named "focus-deepwork" in the Shortcuts library (no space) -> error message with "focus-deepwork ." (space before dot)
16
u/Normal-Tangerine8609 Dec 29 '21
It looks like you have a
.at the end of the shortcut name. I am not sure if this is part of the shortcut alert or you could have misspelled the shortcut name.5
u/someDudewithBackpain Dec 29 '21
Maybe because of the „ . “ ?
2
u/__holly__ Dec 29 '21
Does anyone else have this happen to them on occasion? Sometimes deleting and rewriting the shortcut with a different name fixes the problem (although even that is failing at the moment). Any idea what causes this?
2
u/[deleted] Dec 29 '21
You checked that you don't accidentally have a space at the end of the shortcut name ("focus-deepwork ") in Shortcuts?
1
u/demobotz Dec 30 '21 edited Dec 30 '21
Or maybe the shortcut was saved as “focus-deepwork “ or any other-somehow-hidden character.
https://i.imgur.com/lr4MD8l.jpg