예제 #1
0
def update():
    installed = Popen(["cat", bat + "installed"], stdout=PIPE).stdout.read()
    if installed == "0":
        return set_color(i('ac_01', False), fg)
    else:
        status = Popen(["cat", bat + "state"], stdout=PIPE).stdout.read()
        if status == "idle\n":
            return set_color(i('ac_01', False),fg)
        elif status == "charging\n":
            percent = Popen(["cat", bat + "remaining_percent"],stdout=PIPE).stdout.read()[:-1]
            time = Popen(["cat", bat + "remaining_charging_time"],stdout=PIPE).stdout.read()[:-1]
            if time == "not_charging":
                    return set_color("%s%s%%" % (i ('ac_01'),percent), fg)
            return set_color("%s%s%% %s" % (i ('ac_01'),percent, time), fg)
        elif status == "discharging\n":
            percent = Popen(["cat", bat + "remaining_percent"],stdout=PIPE).stdout.read()[:-1]
            time = Popen(["cat", bat + "remaining_running_time"],stdout=PIPE).stdout.read()[:-1]
            if time == "not_discharging":
                if int(percent) > 66:
                    return set_color("%s%s%%" % (i ('bat_full_01'),percent), fg)
                elif int(percent) < 33:
                    return set_color("%s%s%%" % (i ('bat_empty'),percent), fg)
                else:
                    return set_color("%s%s%%" % (i ('bat_low_01'),percent), fg)
            if int(percent) > 66:
                return set_color("%s%s%% %s" % (i ('bat_full_01'),percent, time), fg)
            elif int(percent) < 33:
                return set_color("%s%s%% %s" % (i ('bat_empty_01'),percent, time), fg)
            else:
                return set_color("%s%s%% %s" % (i ('bat_low_01'),percent, time), fg)
예제 #2
0
def update():
    try:
        status = mpdHook.status()['state']
        if status == 'play':
            song = mpdHook.currentsong()
            return set_color("%s%s - %s" %(i('play'), song['artist'], song['title']), fg)
        elif status == 'pause':
            song = mpdHook.currentsong()
            return set_color("%s%s - %s" % (i('pause'), song['artist'], song['title']), fg)
        elif status == 'stop':
            return set_color(i('stop', False), fg)
    except mpd.ConnectionError:
        return set_color("MPD not available", fg)
예제 #3
0
	def __setattr__(self, attribute, value):
		"""
		Set an attribute. See L{SVGElement.__setattr__} for more information, as
		this function passes on unresolved attributes to it.
		
		@type attribute: string
		@param attribute: The name of the attribute being set.
		@type value: string or number
		@param value: The value of the attribute being set.
		"""
		if attribute == "color":
			set_color(self, SVGElement, "stop-color", "stop-opacity", value)
		else:
			SVGElement.__setattr__(self, attribute, value)
예제 #4
0
def main():
    # Setup the screen
    pygame.init()
    display = pygame.display.set_mode((800,600))
    pygame.display.set_caption("Fallen Spire")

    loader.set_base_path(os.path.join("..", "media"))

    display.fill((0,0,0))

    if (0):
        display.fill((255,255,255))
        img = loader.load_image(os.path.join("items", "compass.png"))
        img = utils.set_color(img, (0,0,0))
        utils.adjust_alpha(img, 170)

        img = utils.blur_surf(img)
        display.blit(img, (0, 0))

        img = loader.load_image(os.path.join("items", "compass.png"))
        display.blit(img, (1, 2))

        pygame.display.flip()
        while 1:
            ev = pygame.event.wait()
            if (ev.type == pygame.KEYDOWN): break
        return

    game = GameInterface()
    game.mainloop()
예제 #5
0
	def __setattr__(self, attribute, value):
		"""
		Set an attribute. This function is used to set the "stroke" attribute;
		if the attribute being set isn't "stroke" None will be returned.
		
		@type attribute: string
		@param attribute: The name of the attribute being set.
		@type value: string or number
		@param value: The value of the attribute being set.
		@rtype: boolean
		@return: True if the fill was set, otherwise False.
		"""
		if attribute == "stroke":
			set_color(self, SVGElement, "stroke", "stroke-opacity", value)
			return True
		else:
			return False
예제 #6
0
def update():
    network = "kijowyRouter(StacjaMarsjanska)"
    p = subprocess.Popen(["iwconfig", interface], stdout=subprocess.PIPE)
    response = p.stdout.read().split("  ")
    tmp = [x for x in response if "ESSID" in x][0]
    if "off" in tmp:
        return None
    else:
        tmp = [x for x in response if "Link Quality" in x][0].split('=')[1]
        tmp = tmp.split('/')
        temp = float(tmp[0])/float(tmp[1])*100
        return set_color("%s%i%%" % ( i('wifi_02'), temp), fg)
예제 #7
0
    def __init__(this, path, offset=(0,0)):
        img = loader.load_image(path)
        this.normal = GameInterface.add_shadow(img)

        img = utils.darken_surf(img, -30)
        this.highlight = GameInterface.add_shadow(img)
        this.pressed = img
        this.size = this.normal.get_size()
        # Create an image mask for blanking out the button
        this.blank = utils.set_color(this.normal, (255,255,255))
        utils.adjust_alpha(this.blank, 255*255)
        this.itemOffset = offset
예제 #8
0
    def execute(self, speedup=1, pause=True):
        self.remove_plots()
        # make all objects fully opaque
        utils.set_transparency(self.robot, 0)
        tfs = {}
        tfs[self.robot.GetName()] = self.robot.GetTransform()
        for obj_name in self.world.movable_objects:
            utils.set_transparency(self.env.GetKinBody(obj_name), 0)
            tfs[obj_name] = self.env.GetKinBody(obj_name).GetTransform()

        if pause:
            raw_input("Press enter to run in simulation!")
        for action in self.action_list:
            if action.name.startswith("move"):
                T = self.robot.GetTransform()
                if action.obj:
                    obj = self.env.GetKinBody(action.obj.name)
                    obj_T = obj.GetTransform()
                for ts in range(action.traj.num_timesteps()):
                    T[:3, 3] = action.traj.get_value()[:, ts]
                    self.robot.SetTransform(T)
                    if action.obj:
                        assert action.traj.num_timesteps() == action.obj_traj.num_timesteps()
                        obj_T[:3, 3] = action.obj_traj.get_value()[:, ts]
                        obj.SetTransform(obj_T)
                    time.sleep(0.02 / speedup)
            if action.name.startswith("pick"):
                utils.set_color(action.obj.get_env_body(self.env), [0, 1, 0])
            if action.name.startswith("place"):
                utils.set_color(action.obj.get_env_body(self.env), [0, 1, 1])

        # restore transparency
        utils.set_transparency(self.robot, 0.7)
        for obj_name in self.world.movable_objects:
            utils.set_transparency(self.env.GetKinBody(obj_name), 0.7)

        # restore transforms
        for n, t in tfs.items():
            self.env.GetKinBody(n).SetTransform(t)
예제 #9
0
def update():
    global rx_old
    global tx_old
    tx = 0
    rx = 0
    tmp = psutil.network_io_counters(pernic=True)[interface]
    rx = tmp.bytes_recv
    tx = tmp.bytes_sent
    rxps = (rx - rx_old) / 1024
    txps = (tx - tx_old) /1024
    rx_old = rx
    tx_old = tx
    return set_color("%i %s%s%i" % (rxps, i('net_down_01', False),i('net_up_01'), txps), fg)
예제 #10
0
    def render_shadow(this, dest, destpos):
        (x, y) = destpos
        # Create the base shadow image. We want it to be based on the
        # character's current image but a little larger (implying a light
        # source from below).
        shadow = utils.set_color(this.image, (0,0,0,150))
        # Enlarge the shadow a bit
        scale = 1.15
        shadow = pygame.transform.scale(
            shadow, (shadow.get_width(), 
                     int(shadow.get_height()*scale)))
        # Blur the shadow a little
        shadow = utils.blur_surf(shadow, 1)
        # The shadow will be rendered to the left of the character's
        # position, since that is how scene depth is rendered - up and
        # to the left.
        dh = shadow.get_height()-this.image.get_height()
        (xp, yp) = (8, dh+3)
        tileSet = this.level.tileSet

        # Now here's the tricky part. We don't want the shadow to be
        # cast on the backdrop image, but only on the background and
        # midground grids. So, those grids are rendered into a separate
        # buffer, then multiply that buffer's alpha channel by the 
        # shadow's alpha channel to appropriately clip the shadow.
        tmp = pygame.Surface(shadow.get_size()).convert_alpha()
        tmp.fill((0,0,0,0))
        (centerx, centery) = this.level.midground.get_centerline_offset()
        centery += EXTRA_DEPTH_OFFSET

        # Render the background as it would appear under the shadow's image
        this.level.background.render(
            tmp, (0, 0),
            tmp.get_rect().move(this.rect.left+centerx-xp, 
                                this.rect.top+centery-yp), skipObjects=True)

        # Do the same for the midground grid.
        this.level.midground.render(
            tmp, (0, 0),
            tmp.get_rect().move(this.rect.left+centerx-xp,
                                this.rect.top+centery-yp), skipObjects=True)

        # Multiply the alpha channels, effectivly clipping the image
        utils.adjust_alpha(shadow, tmp)
        # Now blit the shadow
        dest.blit(shadow, (x-xp, y-yp))
예제 #11
0
 def __init__(this, brush, nframes=18, color=(150,150,150)):
     appearance.AppearanceFactory.__init__(this, "dust")
     # Assign the brush a color
     brush = utils.set_color(brush, color)
     # Create the frames of the animation
     anim = appearance.Animation()
     for count in xrange(nframes):
         # Figure out the alpha and size of the dust particle
         n = float(count)/(nframes)
         scale = 2.0 + 2.5*n
         alpha = math.sin(n*math.pi)
         img = pygame.transform.rotozoom(brush, 0, scale)
         utils.adjust_alpha(img, int(255*alpha))
         anim.add_frame(img, (0.5, 0.5))
     # Wrap that animation in an action object
     action = appearance.Action()
     action.add_animation("south", anim)
     action.looping = False
     action.fps = 10
     # Now add it as the default action
     this.add_action("Idle", action)
예제 #12
0
def update():
	return set_color("%s%s" % (i('clock'),datetime.datetime.now().strftime("%H:%M")), fg)
예제 #13
0
def update():
    if alsaaudio.Mixer().getmute()[0] == 1:
        return set_color(i('spkr_02', False), fg)
    else:
        return set_color(i('spkr_03') + str(alsaaudio.Mixer().getvolume()[0]) + "%", fg)