felixhageloh / uebersicht

ˈyːbɐˌzɪçt
GNU General Public License v3.0
4.56k stars 166 forks source link

Widget/Button that triggers a keyboard shortcut #468

Open sealevelcain opened 2 years ago

sealevelcain commented 2 years ago

Is it possible to create a widget/button that mimics keyboard input? I would like to create a button that replicates the keyboard shortcut ⌘+§ when pressed.

Rincewind34 commented 2 years ago

I don't know how skilled you are when writing code, but that can be easily achieved running an apple script from the terminal. As proposed by the documentation in the README, add a button

    <button
      onClick={() => {
        run('osascript -e \'tell application "Finder" to activate\'"')
          .then((output) => dispatch({type: 'OUTPUT_UPDATED', output}))
      }}
    >

and change the apple script code to execute a key stroke (enough infos on google including all special cases)

Don't forget the import on top of your widget file import { run } from 'uebersicht'

Best, Rincewind