DWilliames / idasen-controller-mac

A Mac App to control your Idasen Desk
MIT License
243 stars 19 forks source link

Apple script stand-up and sit-down do not work #15

Open akucharczyk opened 2 years ago

akucharczyk commented 2 years ago

I currently writing raycast extension which works with your application and gets the following issue.

Since the new version, the following two apple scripts do not work anymore. I did not get any error message when I run the script. You can check out my code in the following Mr https://github.com/raycast/extensions/pull/1964.

tell application "Desk Controller"
    move "to-sit" // or "to-stand"
end tell
diotav commented 2 years ago

To add, specifying the height manually does work in AppleScript.

tell application "Desk Controller"
    move to "125cm"
end tell
JulianWielga commented 1 year ago

looks like it's simple copy-paste mistake. both command codes in deskcontroller.sdef are the same.

alvarogonzalez-packlink commented 1 year ago

Same for me. I'm running the script in Script Editor and setting the height works, but setting "to-stand" (or "to-sit") doesn't. No errors, no messages.

I'm in the latest Ventura release.

Let me know if I can do anything for debugging.

akucharczyk commented 1 year ago

@alvarogonzalez-packlink I fixed it in my forked branch and added Notification. There is currently no signed or build version uploaded, so you need this to build by your own on your local system.

gmhabchi commented 1 year ago

I wrote a bash script for this which works for me and I thought I'd share if anyone wanted something like it;

#!/bin/bash

ACTION=$1
HEIGHT=$2

# preset heights
SIT="80cm"
STAND="110cm"

# height check values
MAX_HEIGHT=115
MIN_HEIGHT=75

# colours
NOCOLOUR='\033[0m'
RED='\033[0;31m'
ORANGE='\033[0;33m'

warning() {
    echo -e "${RED}$1${NOCOLOUR}"
}

hint() {
    echo -e "${ORANGE}$1${NOCOLOUR}"
}

desk_move() {
    osascript <<EOD
    tell application "Desk Controller"
        move to "$1"
    end tell
EOD
}

height_check() {
    if [ -z $HEIGHT ]; then
        warning "ERROR!"
        echo "Height not supplied"
        exit
    elif (($HEIGHT > $MAX_HEIGHT)); then
        warning "ERROR!"
        echo "Height $HEIGHT is too high"
        exit
    elif (($HEIGHT < $MIN_HEIGHT)); then
        warning "ERROR!"
        echo "Height $HEIGHT is too low"
        exit
    fi
}

if [ "$ACTION" == "sit" ] || [ "$ACTION" == "stand" ]; then
    if [ "$ACTION" == "sit" ]; then VALUE=$SIT; else VALUE=$STAND; fi
    echo "Moving Desk to $ACTION - $VALUE"
    desk_move $VALUE
elif [ "$ACTION" == "height" ]; then
    height_check $HEIGHT
    echo "Moving Desk to height - $HEIGHT"
    desk_move "${HEIGHT}cm"
else
    warning "Missing action"
    hint "Available actions:"
    echo "desk sit"
    echo "desk stand"
    echo "desk height <NUMBER>"
fi
user928 commented 1 year ago

To add, specifying the height manually does work in AppleScript.

tell application "Desk Controller"
    move to "125cm"
end tell

Thanks this is good workaround

patrickrushton commented 6 months ago

This used to work on my previous Mac but strangely it no longer works. Interestingly Script Editor automatically changes move "to-sit" to move to "to-sit"

tell application "Desk Controller"
    move to "to-sit"
end tell