#!/bin/bash

# Tools-tab entry — invoked by `libreportal app tool dashy shortcuts_manage`.
# Resolved by dockerAppRunTool: tool id `shortcuts_manage` →
# function `appDashyManageShortcuts`.
#
# Modal field (see webui_tools.sh):
#   selected — comma-separated app slugs the user wants on the dashboard.
#
# Persists the selection to CFG_DASHY_SHORTCUTS, then regenerates dashy's
# conf.yml via the existing appDashyUpdateConf and restarts the container.
appDashyManageShortcuts()
{
    local tool_args="$1"
    local selected
    selected=$(toolArgsGet "$tool_args" "selected")
    selected="${selected//%7C/|}"

    local cfg_file="${containers_dir}dashy/dashy.config"
    updateConfigOption "CFG_DASHY_SHORTCUTS" "$selected" "$cfg_file"
    export CFG_DASHY_SHORTCUTS="$selected"
    isSuccessful "Saved CFG_DASHY_SHORTCUTS=$selected"

    appDashyUpdateConf
}
