1

Is there a keyboard shortcut to open/drop-down the sound menu/indicator, in order e.g. to see the currently playing song? If not, how could I set one?

2

2 Answers 2

2

With the script below under a shortcut key, you can make any menu item drop down, if no shortcut exists for it, including the sound menu:

enter image description here

It actually is pretty much the same answer as posted here, but the question is different. I took the liberty however to broaden (the title of) your question a bit to cover possible future similar questions.

What it does

The script simulates a mouse move to the menu or icon, clicks and then returns the mouse to where it was. This all happens in a split second, so you won't notice it at all.

It can be used in a flexible way, to click on the screen on any position, to be changed easily. It runs with two options:

  1. to set (remember) the current mouse location:

    run_click -set
    
  2. to click on the last-remembered position:

    run_click -run
    

If no position was set, a zenity message appears, inviting to set a position

The script creates a hidden file; ~/.run_click where it stores the latest remembered coordinates.

How to use

  1. Install xdotool

    sudo apt-get install xdotool
    
  2. Copy the script below into an empty file, save it as open_menu (no extension) in ~/bin. Create the directory if necessary, and make the script executable.

  3. If you just created ~/bin, run source ~/.profile.
  4. Test both commands, first open_menu -set, then open_menu -run to see if all works as expected.
  5. Now create two shortcuts: one to make the script remember the position of your menu item, the second one to actually open the menu. choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the commands to two different shortcut key combinations:

    open_menu -set
    

    and

    open_menu -run
    

Now place the mouse on the sound menu icon and press the first shortcut key. From then on, you can open the menu with the second shortcut key.

The script

#!/usr/bin/env python3
import subprocess
import time
import sys
import os

option = sys.argv[1]
datafile = os.path.join(os.environ["HOME"], ".run_click")

def get_mousepos():
    cursordata = subprocess.check_output(["xdotool", "getmouselocation"]).decode("utf-8").split()
    return [d.split(":")[1] for d in cursordata[:2]]

if option == "-run":
    try:
        data = open(datafile).read()
        coords = (" ").join([l for l in data.splitlines()])
    except FileNotFoundError:
        message = "Please run the command: 'run_click -set' first, to set the click position"
        subprocess.Popen(["zenity", "--info", "--text", message])
    else:
        cmd1 = "xdotool mousemove "+coords; cmd2 = "xdotool click 1"; cmd3 = "xdotool mousemove "+(" ").join(get_mousepos())
        for cmd in [cmd1, cmd2, cmd3]:
            subprocess.Popen(["/bin/bash", "-c", cmd])
            time.sleep(0.05)
elif option == "-set":
    open(datafile, "wt").write(("\n").join(get_mousepos()))
10
  • Generally it works if I run the scripts explicitly. But, I do the steps you suggest and when I try to execute one of these commands I receive a "command not found" error. I tried assigning the full path as a command and it also doesn't work...
    – MakisH
    May 30, 2015 at 20:37
  • @MakisH What do you mean by explicitely? It should always work! If not let me know. May 30, 2015 at 20:39
  • Sorry, I accidentaly pressed enter while commenting. I editted my comment.
    – MakisH
    May 30, 2015 at 20:40
  • @MakisH where do you store the script? under which name? Did you make it executable? Also important: did you either run source ~/.profile or log out/in? It is needed if you just created the directory ~/bin to make it show up in $PATH. May 30, 2015 at 20:44
  • 1
    So, I was able to run it with your suggestion in chat: "python3 /absolute/path/to/open_menu -run" Thanks for the answer! :-)
    – MakisH
    May 30, 2015 at 21:27
0

There is not a specific shorcut to open the Sound Indicator, but you can press Alt+F10 to focus the Menu Indicator and translate to the Sound Indicator.

1
  • I already had found this but, unfortunately, it doesn't work if I have e.g. a firefox window active. Thank's for the answer though! :)
    – MakisH
    May 30, 2015 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.