various small changes
This commit is contained in:
		
							parent
							
								
									cdf5996c40
								
							
						
					
					
						commit
						9976e7f144
					
				
					 3 changed files with 15 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -262,6 +262,7 @@ class MediaWidget(base.InLoopPollText):
 | 
			
		|||
        ('on_text_stop', ' {}', 'The pattern for the text if music is stopped.'),
 | 
			
		||||
        ('update_interval', 1, 'The update interval.'),
 | 
			
		||||
        ('max_chars_per_player', 50, 'Maximum characters of text per player.'),
 | 
			
		||||
        ('ignore_players', '', 'Comma-separated list of players to ignore.')
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    player_icons = {
 | 
			
		||||
| 
						 | 
				
			
			@ -319,13 +320,13 @@ class MediaWidget(base.InLoopPollText):
 | 
			
		|||
        if button == BUTTON_LEFT:
 | 
			
		||||
            player = self._player_to_control()
 | 
			
		||||
            if player is not None:
 | 
			
		||||
                command = ["playerctl", "-p", player, "play-pause"]
 | 
			
		||||
                command = ["playerctl", "-i", self.ignore_players, "-p", player, "play-pause"]
 | 
			
		||||
                _ = self.call_process(command)
 | 
			
		||||
                notify("MediaWidget", "Toggled {}".format(player))
 | 
			
		||||
        if button == BUTTON_RIGHT:
 | 
			
		||||
            player = self._player_to_control()
 | 
			
		||||
            if player is not None:
 | 
			
		||||
                command = ["playerctl", "-p", player, "next"]
 | 
			
		||||
                command = ["playerctl", "-i", self.ignore_players, "-p", player, "next"]
 | 
			
		||||
                _ = self.call_process(command)
 | 
			
		||||
        if button == BUTTON_MIDDLE:
 | 
			
		||||
            # Jump to the screen that the player is on
 | 
			
		||||
| 
						 | 
				
			
			@ -358,7 +359,7 @@ class MediaWidget(base.InLoopPollText):
 | 
			
		|||
 | 
			
		||||
        # Playerctl players
 | 
			
		||||
        try:
 | 
			
		||||
            result = self.call_process(["playerctl", "-l"])
 | 
			
		||||
            result = self.call_process(["playerctl", "-i", self.ignore_players, "-l"])
 | 
			
		||||
        except subprocess.CalledProcessError:
 | 
			
		||||
            result = None
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -398,17 +399,17 @@ class MediaWidget(base.InLoopPollText):
 | 
			
		|||
 | 
			
		||||
                else:
 | 
			
		||||
                    # PlayerCtl player
 | 
			
		||||
                    command = ["playerctl", "-p", player, "status"]
 | 
			
		||||
                    command = ["playerctl", "-i", self.ignore_players, "-p", player, "status"]
 | 
			
		||||
                    cmd_result = self.call_process(command).strip()
 | 
			
		||||
 | 
			
		||||
                    text = "Unknown"
 | 
			
		||||
                    if cmd_result in ["Playing", "Paused"]:
 | 
			
		||||
                        try:
 | 
			
		||||
                            artist = self.call_process(['playerctl', '-p', player, 'metadata', 'artist']).strip()
 | 
			
		||||
                            artist = self.call_process(['playerctl', "-i", self.ignore_players, '-p', player, 'metadata', 'artist']).strip()
 | 
			
		||||
                        except subprocess.CalledProcessError:
 | 
			
		||||
                            artist = None
 | 
			
		||||
                        try:
 | 
			
		||||
                            title = self.call_process(['playerctl', '-p', player, 'metadata', 'title']).strip()
 | 
			
		||||
                            title = self.call_process(['playerctl', "-i", self.ignore_players, '-p', player, 'metadata', 'title']).strip()
 | 
			
		||||
                        except subprocess.CalledProcessError:
 | 
			
		||||
                            title = None
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue