From 78dbe320e06872d3f3f9a624c34b425e008ad460 Mon Sep 17 00:00:00 2001 From: Shy Date: Thu, 6 Apr 2017 18:45:51 +0200 Subject: [PATCH] Do not use fluffyd by default --- c4ctrl.py | 32 ++++++++++++++++---------------- c4ctrl.vim | 13 ++++++------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/c4ctrl.py b/c4ctrl.py index 9cc06f3..2248c64 100755 --- a/c4ctrl.py +++ b/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: # .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() diff --git a/c4ctrl.vim b/c4ctrl.vim index 3a100e7..c094c88 100644 --- a/c4ctrl.vim +++ b/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 " *************************** "