marketplace/apps

Morning Desk

v0.1.0

@rebindfree

One key opens your work apps, places each window on its half of the screen, and starts your music.

Gallery

Morning Desk preview

Readme

Press F1 and Rebind opens your work apps, places each window on its part of the screen, and starts your music. By default Linear goes on the left half, Notion on the right half, and Spotify starts playing.

Needs Rebind 3.5.0 or newer on Windows or macOS. It requests the exec permission so it can start programs on Windows.

Set up

On the Apps and Music tabs, set each app's name, where it goes, and on Windows how to start it:

  • macOS: the name is the app's name, such as Notion. macOS opens it if it is not running.
  • Windows: the name is the program's file name without .exe, such as Notion. If the app is closed, Rebind starts it with the launch command when you set one (the full path to the program), and otherwise asks Windows to start it by name, which works only for apps Windows can find that way.

Leave an app name empty to skip it.

Settings

  • Open and arrange the day: default F1. Key changes apply while the package runs on Rebind 3.9 or newer; on older versions, restart the package.
  • First app goes and Second app goes: Left half, Right half, or Full screen: the screen under the pointer on Windows (without the taskbar), the main screen on macOS.
  • Start playing: on Windows Rebind presses the Play media key; on macOS it presses Space in the music app, which plays or pauses Spotify.

Limits

  • Each app gets up to 5 seconds to come to the front; if it does not, a notice says so and the next app goes on. Notices appear in Rebind; to see them on the desktop, turn on Desktop notifications in Rebind's settings.
  • Play is a toggle: if music is already playing, it pauses.
  • Live use remains unverified on Windows and macOS.

Stop

Stop the package from the editor toolbar, or press Left Ctrl + Left Alt + K to stop all scripts.

Reviews

No reviews yet. Be the first, from the app.

Source

Version 0.1.0 (current)

main.luau

-- Morning Desk: one key opens your work apps, puts each on its part of the
-- screen, and starts your music.

local IS_MAC = _REBIND.platform == "macos"
local PLACES = { "Left half", "Right half", "Full screen" }

local cfg = UI.Schema({
  key = UI.Keybind("F1", { label = "Open and arrange the day" }),
  firstApp = UI.Text("Linear", { label = "First app", tab = "Apps" }),
  firstPlace = UI.Select("Left half", PLACES, { label = "First app goes", tab = "Apps" }),
  firstLaunch = UI.Text("", {
    label = "First app launch command (Windows)",
    placeholder = "path to the program, if Windows cannot find it",
    tab = "Apps",
  }),
  secondApp = UI.Text("Notion", { label = "Second app", tab = "Apps" }),
  secondPlace = UI.Select("Right half", PLACES, { label = "Second app goes", tab = "Apps" }),
  secondLaunch = UI.Text("", {
    label = "Second app launch command (Windows)",
    placeholder = "path to the program, if Windows cannot find it",
    tab = "Apps",
  }),
  musicApp = UI.Text("Spotify", { label = "Music app", tab = "Music" }),
  musicLaunch = UI.Text("", {
    label = "Music app launch command (Windows)",
    placeholder = "path to the program, if Windows cannot find it",
    tab = "Music",
  }),
  playMusic = UI.Toggle(true, { label = "Start playing", tab = "Music" }),
})

-- Windows App.Activate only focuses a running app, so launch it first;
-- macOS App.Activate opens it when needed.
local function open(app, launch)
  if not IS_MAC and not App.IsRunning(app) then
    local ok, err
    if launch ~= "" then
      ok, err = pcall(System.ExecDetached, launch, {})
    else
      ok, err = pcall(System.ExecDetached, "cmd", { "/c", "start", "", app })
    end
    if not ok then
      UI.Notify(`Could not open {app}: {err}`, "warning")
      return false
    end
  end
  -- a cold start takes a moment: keep asking for the app for 5 seconds
  for _ = 1, 50 do
    pcall(App.Activate, app)
    if App.IsFront(app) then
      return true
    end
    Sleep(100)
  end
  UI.Notify(`{app} did not come to the front`, "warning")
  return false
end

local function area()
  if not IS_MAC then
    local ok, rect = pcall(Screen.WorkArea)
    if ok then
      return rect.x, rect.y, rect.width, rect.height
    end
  end
  local w, h = System.Screen()
  return 0, 0, w, h
end

local function place(where)
  local x, y, w, h = area()
  if where == "Left half" then
    Window.Move(nil, x, y, w // 2, h)
  elseif where == "Right half" then
    Window.Move(nil, x + w // 2, y, w - w // 2, h)
  else
    Window.Move(nil, x, y, w, h)
  end
end

Bind(
  cfg.key,
  Async(function()
    for _, slot in { "first", "second" } do
      local app = cfg[slot .. "App"]
      if app ~= "" and open(app, cfg[slot .. "Launch"]) then
        Sleep(300)
        place(cfg[slot .. "Place"])
      end
    end
    if cfg.musicApp ~= "" and open(cfg.musicApp, cfg.musicLaunch) and cfg.playMusic then
      Sleep(800)
      -- macOS software mode cannot send media keys, so ask the app itself
      if IS_MAC then
        HID.Combo("Space")
      else
        pcall(HID.Combo, "MediaPlay")
      end
    end
  end)
)