gnome-shell-extension-better-volume_0.0-git20170425.1a66fab/0000755000175000017500000000000013127134622023371 5ustar jonathanjonathangnome-shell-extension-better-volume_0.0-git20170425.1a66fab/bundle.sh0000755000175000017500000000020213127134602025171 0ustar jonathanjonathan#!/usr/bin/bash zip -r bundle.zip \ extension.js \ convenience.js \ metadata.json \ LICENSE.rst \ README.rst; gnome-shell-extension-better-volume_0.0-git20170425.1a66fab/convenience.js0000644000175000017500000000113513127134602026221 0ustar jonathanjonathan// Print objects... why no dev tools function dbPrintObj (name, obj, recurse, _indent) { let prefix = ''; let indent = typeof _indent === 'number' ? _indent : 0; for (let i = 0; i < indent; i++) { prefix += ' '; } log(prefix + '--------------'); log(prefix + name); log(prefix + '--------------'); for (let k in obj) { if (typeof obj[k] === 'object' && recurse) { dbPrintObj(name + '::' + k, obj[k], true, indent + 1); } else { log(prefix + k, typeof obj[k] === 'function' ? '[Func]' : obj[k]); } } } gnome-shell-extension-better-volume_0.0-git20170425.1a66fab/.gitignore0000644000175000017500000000000613127134602025353 0ustar jonathanjonathan*.zip gnome-shell-extension-better-volume_0.0-git20170425.1a66fab/metadata.json0000644000175000017500000000067613127134602026053 0ustar jonathanjonathan{ "shell-version": [ "3.10", "3.12", "3.14", "3.16", "3.18", "3.20", "3.22", "3.24" ], "uuid": "bettervolume@tudmotu.com", "name": "Better Volume Indicator", "description": "Display volume level while scrolling the indicator, and allow to toggle mute using the scroll/middle button.", "url": "https://github.com/Tudmotu/gnome-shell-extension-bettervolume" } gnome-shell-extension-better-volume_0.0-git20170425.1a66fab/extension.js0000644000175000017500000001525713127134602025753 0ustar jonathanjonathan/** * Better Volume Indicator * * This simple extension implements two things: * 1. When scrolling on the volume indicator, the volume slider/menu appears to * display current level. * 2. Middle/scroll clicking on the indicator, output is muted. * */ const Clutter = imports.gi.Clutter; const Mainloop = imports.mainloop; const Main = imports.ui.main; const PanelMenu = imports.ui.panelMenu; const VolumeMenu = imports.ui.status.volume.VolumeMenu; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); const Convenience = Me.imports.convenience; const prettyPrint = Convenience.dbPrintObj; const POPUP_TIMEOUT_SECS = 1; const VOLUME_MUTE_ICON = 'audio-volume-muted-symbolic'; let onlyVolumeMenuShown = false; let volumeIndicator; let aggregateMenu; let _onAggregateMenuClickEventId; let _onAggregateMenuEnterEventId; let _onAggregateMenuLeaveEventId; let _onVolumeIndicatorScrollEventId; let _onVolumeIndicatorClickEventId; let popupTimeout = null; let availableMenus = []; function _onVolumeIndicatorScroll(indicators, e) { let menu = aggregateMenu.menu; // Only if menu is not already open (and not due to our request) if (menu.actor.visible && popupTimeout === null) return; // We need to remove the previous timeout if the user scrolled again since // it means they are not ready yet for us to hide the menu if (popupTimeout !== null) _removeTimeout(); // Set a timeout for the menu to close (we don't want it staying open forever) _setTimeout(); // We want to hide all menus which are not the volume menu _setMenusVisibility(false); // Open the aggregateMenu so we can see some volume aggregateMenu.menu.open(); } function _onVolumeIndicatorScrollTimeout () { // When time is up, we close the menu aggregateMenu.menu.close(); // Re-show the aggegate menu entries _setMenusVisibility(true); _removeTimeout(); } function _onAggregateMenuClick (actor, e) { // Make sure menus are displayed _setMenusVisibility(true); // We want to see if the popup is already displayed, and if so, kill its // timeout, so it won't suddenly disappear on us // If it's not open, we don't won't to do anything if (popupTimeout !== null) { _removeTimeout(); // Make sure the menu is open // This is kinda hacky - since the aggregateMenu toggles its own // visibility, we want to reverse the effect. It's a dirty trick but I // could not figure out a better way to overcome its self-toggling aggregateMenu.menu.toggle(); } } function _onAggregateMenuEnter () { _removeTimeout(); } function _onAggregateMenuLeave () { // When mouse leaves, set a new timeout only if menu was shown due to // volume-scrolling (meaning - this extension caused the menu to appear, and // not, say, a click on the aggregate-menu by the user) if (onlyVolumeMenuShown) _setTimeout(); } let _previousVolumeValue, _previousVolumeIcon; function _onVolumeIndicatorClick (actor, e) { // When middle-clicking on the indicator we want to toggle mute if (e.get_button() === Clutter.BUTTON_MIDDLE) { let sliderActor = volumeIndicator._volumeMenu._output._slider; // hummm.. hack? let currentValue = sliderActor._getCurrentValue(); // starting to look like a hack let currentIcon = volumeIndicator._primaryIndicator.icon_name; if (currentValue === 0 && _previousVolumeValue) { // this is definitely a hack sliderActor.setValue(_previousVolumeValue); sliderActor.emit('value-changed', _previousVolumeValue); // mimic slider behvaiour so volume will actually change volumeIndicator._primaryIndicator.icon_name = _previousVolumeIcon; } else { // a dirty dirty hack sliderActor.setValue(0); sliderActor.emit('value-changed', 0); // like above volumeIndicator._primaryIndicator.icon_name = VOLUME_MUTE_ICON; _previousVolumeValue = currentValue; _previousVolumeIcon = currentIcon; } aggregateMenu.menu.toggle(); // again with that previous hack } } function _setTimeout () { popupTimeout = Mainloop.timeout_add_seconds(POPUP_TIMEOUT_SECS, _onVolumeIndicatorScrollTimeout); } function _removeTimeout () { if (popupTimeout !== null) Mainloop.source_remove(popupTimeout); popupTimeout = null; } function _setMenusVisibility (visibility) { // Find the menus inside the aggregateMenu (I couldn't find a better // way for finding the menus except finding their indicators. seems to work // though) for (let k in aggregateMenu) { let entry = aggregateMenu[k]; if (entry instanceof PanelMenu.SystemIndicator) { if (entry !== volumeIndicator) { entry.menu.actor.visible = visibility; } } } // Hide inner menus inside the volume section volumeIndicator.menu._getMenuItems().forEach(function (item, i) { if ( !(item instanceof VolumeMenu) ) { item.actor.visible = visibility; } }); // Mark volume menu visibility accordingly onlyVolumeMenuShown = !visibility; } function init() { } function enable() { aggregateMenu = Main.panel.statusArea.aggregateMenu; if (aggregateMenu.hasOwnProperty('_volume') && aggregateMenu._volume instanceof PanelMenu.SystemIndicator) { volumeIndicator = aggregateMenu._volume; _onVolumeIndicatorScrollEventId = volumeIndicator.indicators.connect('scroll-event', _onVolumeIndicatorScroll); _onVolumeIndicatorClickEventId = volumeIndicator.indicators.connect('button-press-event', _onVolumeIndicatorClick); _onAggregateMenuEnterEventId = aggregateMenu.menu.actor.connect('enter-event', _onAggregateMenuEnter); _onAggregateMenuLeaveEventId = aggregateMenu.menu.actor.connect('leave-event', _onAggregateMenuLeave); _onAggregateMenuClickEventId = aggregateMenu.actor.connect('button-press-event', _onAggregateMenuClick); } } function disable() { // We need to verify we still have connections and disconnect them if (_onVolumeIndicatorScrollEventId) volumeIndicator.indicators.disconnect(_onVolumeIndicatorScrollEventId); if (_onVolumeIndicatorClickEventId) volumeIndicator.indicators.disconnect(_onVolumeIndicatorClickEventId); if (_onAggregateMenuEnterEventId) aggregateMenu.menu.actor.disconnect(_onAggregateMenuEnterEventId); if (_onAggregateMenuLeaveEventId) aggregateMenu.menu.actor.disconnect(_onAggregateMenuLeaveEventId); if (_onAggregateMenuClickEventId) aggregateMenu.actor.disconnect(_onAggregateMenuClickEventId); } gnome-shell-extension-better-volume_0.0-git20170425.1a66fab/LICENSE.rst0000644000175000017500000000222613127134602025205 0ustar jonathanjonathan====================== The MIT License (MIT) ====================== Copyright (c) 2014, Yotam Bar-On ----------------------------------------- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: *The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.* **THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.** gnome-shell-extension-better-volume_0.0-git20170425.1a66fab/README.rst0000644000175000017500000000211313127134602025053 0ustar jonathanjonathan============================ Better Volume Indicator ============================ This simple extension implements two small features: #. When using the mouse-scroll over the volume indicator, the volume slider appears and displays the appropriate level. #. Clicking on the volume indicator using the mouse middle button will toggle output mute. Extension page on e.g.o: https://extensions.gnome.org/extension/759/better-volume-indicator/ Installation ---------------- Installtaion via git is performed by cloning the repo into your local gnome-shell extensions directory (usually ~/.local/share/gnome-shell/extensions/):: $ git clone https://github.com/Tudmotu/gnome-shell-extension-bettervolume.git /bettervolume@tudmotu.com After cloning the repo, the extension is practically installed yet disabled. In order to enable it, you need to use gnome-tweak-tools - find the extension, titled 'Better Volume Indicator', in the 'Extensions' screen and turn it 'On'. You may need to restart the shell (Alt+F2 and insert 'r' in the prompt) for the extension to be listed there.