This repository has been archived by the owner on Jan 10, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 54ef771
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const Lang = imports.lang; | ||
const Main = imports.ui.main; | ||
const PopupMenu = imports.ui.popupMenu; | ||
|
||
const AudioOutputSubMenu = new Lang.Class({ | ||
Name: 'AudioOutputSubMenu', | ||
Extends: PopupMenu.PopupSubMenuMenuItem, | ||
|
||
_init: function() { | ||
this.parent('Audio Output: Connecting...', true); | ||
|
||
this._control = Main.panel.statusArea.aggregateMenu._volume._control; | ||
|
||
this._control.connect('default-sink-changed', Lang.bind(this, function() { | ||
this._updateDefaultSink(); | ||
})); | ||
|
||
this._updateDefaultSink(); | ||
|
||
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) { | ||
if (isOpen) | ||
this._updateSinkList(); | ||
})); | ||
|
||
//Unless there is at least one item here, no 'open' will be emitted... | ||
item = new PopupMenu.PopupMenuItem('Connecting...'); | ||
this.menu.addMenuItem(item); | ||
}, | ||
|
||
_updateDefaultSink: function () { | ||
this.label.set_text(this._control.get_default_sink().get_description()); | ||
}, | ||
|
||
_updateSinkList: function () { | ||
this.menu.removeAll(); | ||
|
||
sinklist = this._control.get_sinks(); | ||
control = this._control; | ||
|
||
for (i = 0; i < sinklist.length; i++) { | ||
sink = sinklist[i]; | ||
item = new PopupMenu.PopupMenuItem(sink.get_description()); | ||
item.connect('activate', Lang.bind(sink, function() { | ||
control.set_default_sink(this); | ||
})); | ||
this.menu.addMenuItem(item); | ||
} | ||
}, | ||
}); | ||
|
||
let audioOutputSubMenu = null; | ||
|
||
function init() { | ||
} | ||
|
||
function enable() { | ||
if (audioOutputSubMenu != null) | ||
return; | ||
audioOutputSubMenu = new AudioOutputSubMenu(); | ||
Main.panel.statusArea.aggregateMenu._volume.menu.addMenuItem(audioOutputSubMenu); | ||
} | ||
|
||
function disable() { | ||
audioOutputSubMenu.destroy(); | ||
audioOutputSubMenu = null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"shell-version": [ | ||
"3.10" | ||
], | ||
"uuid": "audio-output-switcher@anduchs", | ||
"name": "Audio Output Switcher", | ||
"description": "Adds a switch for choosing audio output to the system menu.", | ||
"url": "http://github.com/anduchs/audio-output-switcher" | ||
} |