diff options
| author | dvs1 | 2024-10-22 17:03:41 +1000 |
|---|---|---|
| committer | dvs1 | 2024-10-22 17:03:41 +1000 |
| commit | d0c90692ab3438b332f6da1e485617f9de9a7412 (patch) | |
| tree | 18b924affc7016eee5078ea161fc71d1bcffd033 | |
| parent | Make the user command STOP, so stop is for SysV. (diff) | |
| download | JackOnAllDevices-d0c90692ab3438b332f6da1e485617f9de9a7412.zip JackOnAllDevices-d0c90692ab3438b332f6da1e485617f9de9a7412.tar.gz JackOnAllDevices-d0c90692ab3438b332f6da1e485617f9de9a7412.tar.bz2 JackOnAllDevices-d0c90692ab3438b332f6da1e485617f9de9a7412.tar.xz | |
Rearrange those logging globals and a few other things in _.
| -rwxr-xr-x | .aataaj_JACK.lua | 7 | ||||
| -rwxr-xr-x | _.lua | 77 | ||||
| -rwxr-xr-x | aataaj.lua | 7 | ||||
| -rwxr-xr-x | test_.lua | 15 |
4 files changed, 40 insertions, 66 deletions
diff --git a/.aataaj_JACK.lua b/.aataaj_JACK.lua index 91888d2..d659d50 100755 --- a/.aataaj_JACK.lua +++ b/.aataaj_JACK.lua | |||
| @@ -3,12 +3,5 @@ | |||
| 3 | -- An example users .aataaj_JACK.lua script that just starts qsynth. | 3 | -- An example users .aataaj_JACK.lua script that just starts qsynth. |
| 4 | 4 | ||
| 5 | local _ = require '_' | 5 | local _ = require '_' |
| 6 | local D = _.D | ||
| 7 | local I = _.I | ||
| 8 | local T = _.T | ||
| 9 | local W = _.W | ||
| 10 | local E = _.E | ||
| 11 | local C = _.C | ||
| 12 | local __ = _._ | ||
| 13 | 6 | ||
| 14 | if _.runnable'qsynth' then __'qsynth':forkOnce() end | 7 | if _.runnable'qsynth' then __'qsynth':forkOnce() end |
| @@ -3,21 +3,41 @@ | |||
| 3 | 3 | ||
| 4 | -- Most of this _ stuff was copied from apt-panopticon. | 4 | -- Most of this _ stuff was copied from apt-panopticon. |
| 5 | local _ = {} | 5 | local _ = {} |
| 6 | |||
| 7 | _.version = '0.0 crap' | 6 | _.version = '0.0 crap' |
| 8 | 7 | ||
| 9 | _.D = function(s) print('DEBUG ' .. s) end | 8 | |
| 10 | _.I = function(s) print('INFO ' .. s) end | 9 | D = function(s) print('DEBUG ' .. s) end |
| 11 | _.T = function(s) print('TIMEOUT ' .. s) end | 10 | I = function(s) print('INFO ' .. s) end |
| 12 | _.W = function(s) print('WARNING ' .. s) end | 11 | T = function(s) print('TIMEOUT ' .. s) end |
| 13 | _.E = function(s) print('ERROR ' .. s) end | 12 | W = function(s) print('WARNING ' .. s) end |
| 14 | _.C = function(s) print('CRITICAL ' .. s) end | 13 | E = function(s) print('ERROR ' .. s) end |
| 15 | local D = _.D | 14 | C = function(s) print('CRITICAL ' .. s) end |
| 16 | local I = _.I | 15 | |
| 17 | local T = _.T | 16 | |
| 18 | local W = _.W | 17 | _.runnable = function(c) |
| 19 | local E = _.E | 18 | return ( 0 == __('which ' .. c):Do().status ) |
| 20 | local C = _.C | 19 | end |
| 20 | |||
| 21 | _.running = function(c) | ||
| 22 | return ( 1 ~= tonumber(__("pgrep -u $USER -cf " .. c):Do().lines[1]) ) | ||
| 23 | end | ||
| 24 | |||
| 25 | _.exists = function(f) | ||
| 26 | local h, e = io.open(f, "r") | ||
| 27 | if nil == h then return false else h:close(); return true end | ||
| 28 | end | ||
| 29 | |||
| 30 | _.killEmAll = function(all) | ||
| 31 | for i,l in ipairs(all) do | ||
| 32 | local c = 0 | ||
| 33 | while 0 ~= tonumber(__("pgrep -u $USER -xc " .. l):Do().lines[1]) do | ||
| 34 | local s = 'TERM' | ||
| 35 | if c > 1 then s = 'KILL'; __("sleep " .. c):Do() end | ||
| 36 | __("pkill -" .. s .. " -u $USER -x " .. l):log():Do() | ||
| 37 | c = c + 1 | ||
| 38 | end | ||
| 39 | end | ||
| 40 | end | ||
| 21 | 41 | ||
| 22 | 42 | ||
| 23 | _.readCmd = function(cmd) | 43 | _.readCmd = function(cmd) |
| @@ -33,8 +53,7 @@ _.readCmd = function(cmd) | |||
| 33 | return result | 53 | return result |
| 34 | end | 54 | end |
| 35 | 55 | ||
| 36 | 56 | __ = function(c) | |
| 37 | _._ = function(c) | ||
| 38 | local exe = {status = 0, lines = {}, logging = false, showing = false, cmd = '', command = c} | 57 | local exe = {status = 0, lines = {}, logging = false, showing = false, cmd = '', command = c} |
| 39 | local n = 0 | 58 | local n = 0 |
| 40 | 59 | ||
| @@ -165,33 +184,5 @@ _._ = function(c) | |||
| 165 | return exe | 184 | return exe |
| 166 | end | 185 | end |
| 167 | 186 | ||
| 168 | local __ = _._ | ||
| 169 | |||
| 170 | _.runnable = function(c) | ||
| 171 | return ( 0 == __('which ' .. c):Do().status ) | ||
| 172 | end | ||
| 173 | |||
| 174 | _.running = function(c) | ||
| 175 | return ( 1 ~= tonumber(__("pgrep -u $USER -cf " .. c):Do().lines[1]) ) | ||
| 176 | end | ||
| 177 | |||
| 178 | _.exists = function(f) | ||
| 179 | local h, e = io.open(f, "r") | ||
| 180 | if nil == h then return false else h:close(); return true end | ||
| 181 | end | ||
| 182 | |||
| 183 | _.killEmAll = function(all) | ||
| 184 | for i,l in ipairs(all) do | ||
| 185 | local c = 0 | ||
| 186 | while 0 ~= tonumber(__("pgrep -u $USER -xc " .. l):Do().lines[1]) do | ||
| 187 | local s = 'TERM' | ||
| 188 | if c > 1 then s = 'KILL'; __("sleep " .. c):Do() end | ||
| 189 | __("pkill -" .. s .. " -u $USER -x " .. l):log():Do() | ||
| 190 | c = c + 1 | ||
| 191 | end | ||
| 192 | end | ||
| 193 | end | ||
| 194 | |||
| 195 | |||
| 196 | 187 | ||
| 197 | return _ | 188 | return _ |
| @@ -15,13 +15,6 @@ | |||
| 15 | ]] | 15 | ]] |
| 16 | 16 | ||
| 17 | local _ = require '_' | 17 | local _ = require '_' |
| 18 | local D = _.D | ||
| 19 | local I = _.I | ||
| 20 | local T = _.T | ||
| 21 | local W = _.W | ||
| 22 | local E = _.E | ||
| 23 | local C = _.C | ||
| 24 | local __ = _._ | ||
| 25 | 18 | ||
| 26 | 19 | ||
| 27 | 20 | ||
| @@ -2,13 +2,6 @@ | |||
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | local _ = require '_' | 4 | local _ = require '_' |
| 5 | local D = _.D | ||
| 6 | local I = _.I | ||
| 7 | local T = _.T | ||
| 8 | local W = _.W | ||
| 9 | local E = _.E | ||
| 10 | local C = _.C | ||
| 11 | local __ = _._ | ||
| 12 | 5 | ||
| 13 | 6 | ||
| 14 | D('Starting from the top.') | 7 | D('Starting from the top.') |
| @@ -114,5 +107,9 @@ print(__'exit 42':log():show():Do().status) | |||
| 114 | print(__'return 42':log():show():Do().status) | 107 | print(__'return 42':log():show():Do().status) |
| 115 | print(__'command NoSuchCommand':log():show():Do().status) | 108 | print(__'command NoSuchCommand':log():show():Do().status) |
| 116 | 109 | ||
| 117 | __'qpdfview':forkOnce() | 110 | --__'qpdfview':forkOnce() |
| 118 | __'qpdfview':forkOnce() | 111 | --__'qpdfview':forkOnce() |
| 112 | |||
| 113 | |||
| 114 | D('debug?') | ||
| 115 | I('info?') \ No newline at end of file | ||
