Do not use fluffyd by default
This commit is contained in:
parent
4c603dc815
commit
78dbe320e0
2 changed files with 22 additions and 23 deletions
32
c4ctrl.py
32
c4ctrl.py
|
@ -243,7 +243,7 @@ class C4Room:
|
|||
|
||||
return self.c4.push(cmd)
|
||||
|
||||
def set_colorscheme(self, colorscheme, no_magic):
|
||||
def set_colorscheme(self, colorscheme, magic):
|
||||
""" Apply colorscheme to the LED Cans in this room. """
|
||||
cmd = []
|
||||
for light in self.lights:
|
||||
|
@ -253,13 +253,7 @@ class C4Room:
|
|||
# <object>.payload later
|
||||
light.set_color(colorscheme.color_for(light.topic))
|
||||
|
||||
if no_magic:
|
||||
# Send data to the real lanterns, not fluffyd.
|
||||
cmd.append({
|
||||
"topic" : light.topic,
|
||||
"payload" : light.payload
|
||||
})
|
||||
else:
|
||||
if magic:
|
||||
# Send color to ghost instead of the "real" light
|
||||
# Generate the ghost topic for topic
|
||||
ghost = "ghosts" + light.topic[light.topic.find('/'):]
|
||||
|
@ -268,13 +262,19 @@ class C4Room:
|
|||
"topic" : ghost,
|
||||
"payload" : light.payload
|
||||
})
|
||||
else:
|
||||
# Send data to the real lanterns, not fluffyd.
|
||||
cmd.append({
|
||||
"topic" : light.topic,
|
||||
"payload" : light.payload
|
||||
})
|
||||
|
||||
if cmd == []: return
|
||||
|
||||
if no_magic:
|
||||
return self.c4.push(cmd)
|
||||
else: # Do not retain "magic" messages
|
||||
if magic: # Do not retain "magic" messages
|
||||
return self.c4.push(cmd, retain=False)
|
||||
else:
|
||||
return self.c4.push(cmd)
|
||||
|
||||
|
||||
class Wohnzimmer(C4Room):
|
||||
|
@ -1041,8 +1041,8 @@ if __name__ == "__main__":
|
|||
"-f", "--fnordcenter", type=str, dest="f_color", metavar="PRESET",
|
||||
help="apply local colorscheme PRESET to Fnordcenter")
|
||||
group_cl.add_argument(
|
||||
"-N", "--no-magic", action="store_true",
|
||||
help="Do not use fluffyd to change colors.")
|
||||
"-M", "--magic", action="store_true",
|
||||
help="Use fluffyd to change colors.")
|
||||
group_cl.add_argument(
|
||||
"-l", "--list-presets", action="store_true",
|
||||
help="list locally available presets")
|
||||
|
@ -1110,15 +1110,15 @@ if __name__ == "__main__":
|
|||
if args.w_color:
|
||||
if args.w_color not in presets:
|
||||
presets[args.w_color] = ColorScheme(autoinit=args.w_color)
|
||||
if presets[args.w_color]: Wohnzimmer().set_colorscheme(presets[args.w_color], args.no_magic)
|
||||
if presets[args.w_color]: Wohnzimmer().set_colorscheme(presets[args.w_color], args.magic)
|
||||
if args.p_color:
|
||||
if args.p_color not in presets:
|
||||
presets[args.p_color] = ColorScheme(autoinit=args.p_color)
|
||||
if presets[args.p_color]: Plenarsaal().set_colorscheme(presets[args.p_color], args.no_magic)
|
||||
if presets[args.p_color]: Plenarsaal().set_colorscheme(presets[args.p_color], args.magic)
|
||||
if args.f_color:
|
||||
if args.f_color not in presets:
|
||||
presets[args.f_color] = ColorScheme(autoinit=args.f_color)
|
||||
if presets[args.f_color]: Fnordcenter().set_colorscheme(presets[args.f_color], args.no_magic)
|
||||
if presets[args.f_color]: Fnordcenter().set_colorscheme(presets[args.f_color], args.magic)
|
||||
if args.list_presets:
|
||||
ColorScheme().list_available()
|
||||
|
||||
|
|
13
c4ctrl.vim
13
c4ctrl.vim
|
@ -1,12 +1,11 @@
|
|||
" This Vim plugin makes some functionality of the c4ctrl utility available
|
||||
" from within Vim.
|
||||
"
|
||||
" Last Change: 2017 Apr 03
|
||||
" Last Change: 2017 Apr 06
|
||||
" Maintainer: Shy
|
||||
" License: This file is placed in the public domain.
|
||||
"
|
||||
" Usage: C4ctrl [get | open PRESET | set [w] [p] [f] [--no-magic] |
|
||||
" text | write]
|
||||
" Usage: C4ctrl [get | open PRESET | set [w] [p] [f] [-magic] | text | write]
|
||||
|
||||
if exists("g:loaded_c4ctrl")
|
||||
finish
|
||||
|
@ -130,8 +129,8 @@ function C4ctrl(command, ...)
|
|||
if stridx("wpf", s:arg) != -1
|
||||
let s:command_line = printf("%s -%s -", s:command_line, s:arg)
|
||||
endif
|
||||
elseif stridx("-no-magic", s:arg) == 0
|
||||
let s:command_line = printf("%s --no-magic", s:command_line)
|
||||
elseif stridx("-magic", s:arg) == 0
|
||||
let s:command_line = printf("%s --magic", s:command_line)
|
||||
endif
|
||||
endfor
|
||||
|
||||
|
@ -240,9 +239,9 @@ function s:C4ctrlCompletion(ArgLead, CmdLine, CursorPos)
|
|||
" Complete the 'set' command "
|
||||
" ************************** "
|
||||
if a:ArgLead != ""
|
||||
return "set\n--no-magic"
|
||||
return "set\n-magic"
|
||||
endif
|
||||
return "w\np\nf\n--no-magic"
|
||||
return "w\np\nf\n-magic"
|
||||
|
||||
elseif stridx("text", get(s:relCmdLine, 1)) == 0
|
||||
" *************************** "
|
||||
|
|
Loading…
Reference in a new issue