summaryrefslogtreecommitdiffstats
path: root/folk.tcl
blob: b747cd59f50f980b7245a9a80c0be20264ab8a68 (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
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env tclsh8.6

set availableActions "Invalid action for manage_folk. Available actions: start, stop, restart"

proc manage_folk {action} {
    switch -- $action {
        "start" -
        "stop" -
        "restart" {
            exec sudo systemctl $action folk
        }
        default {
            puts $availableActions
        }
    }
}

proc calibrate_folk {} {
    exec -ignorestderr tclsh8.6 ~/folk/calibrate.tcl >@stdout
}

if {$argc == 0} {
    puts "Usage: folk <command>"
    puts $availableActions
    exit 1
}

set command [lindex $argv 0]

switch -- $command {
    "start" -
    "stop" -
    "restart" {
        manage_folk $command
    }
    "calibrate" {
        calibrate_folk
    }
    default {
        puts $availableActions
    }
}