summaryrefslogtreecommitdiff
path: root/.local/bin/kak-desktop
blob: f9c1aa365bb897268f5c636bb8390926c7b3c7ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh

main() {
  # Send the edit command to the client
  if [ "$IN_KAKOUNE_CONNECT" ]; then
    :edit "$@"

  # Terminal
  elif test -t 0 -a -t 1; then
    kak "$@"

  # GUI apps
  else
    open "$@"
  fi
}

open() {
  # Skip options
  [ "$1" = '--' ] && shift

  file=$1 line=$2 column=$3
  kak -ui dummy -e "
    new %{
      hook -always -once global ClientClose %val{client} kill!
      edit %{$file} %{$line} %{$column}
    }
  "
}

main "$@"