pax_global_header00006660000000000000000000000064122310044670014511gustar00rootroot0000000000000052 comment=e1ac15a3bb00c204512e0f2c188ea586aae74934 pasystray-0.4.0/000077500000000000000000000000001223100446700135515ustar00rootroot00000000000000pasystray-0.4.0/.gitignore000066400000000000000000000005341223100446700155430ustar00rootroot00000000000000Makefile Makefile.in aclocal.m4 autom4te.cache/ compile config.log config.status configure cscope.out depcomp install-sh missing src/.deps/ src/Makefile src/Makefile.in src/pasystray src/*.o src/config.h.in src/config.h stamp-h1 tags pkg/arch/*/src pkg/arch/*/pkg pkg/arch/*/pasystray-*.tar.* pkg/arch/*/*.pkg.tar.* README.html .gdb_history .*.swp pasystray-0.4.0/AUTHORS000066400000000000000000000001061223100446700146160ustar00rootroot00000000000000pasystray is written by: Christoph Gysin pasystray-0.4.0/LICENSE000066400000000000000000000636371223100446700145750ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! pasystray-0.4.0/Makefile.am000066400000000000000000000022311223100446700156030ustar00rootroot00000000000000# This file is part of PaSystray # # Copyright (C) 2011, 2012 Christoph Gysin # # PaSystray is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # PaSystray is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with PaSystray; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. iconsdir = $(datadir)/icons/hicolor/scalable/apps icons_DATA = data/pasystray.svg pixmapsdir = $(datadir)/pixmaps pixmaps_DATA = data/pasystray.png desktopdir = $(datadir)/applications desktop_DATA = data/pasystray.desktop EXTRA_DIST = bootstrap.sh README.md LICENSE $(icons_DATA) $(pixmaps_DATA) $(desktop_DATA) SUBDIRS = src doc: markdown_py README.md > README.html pasystray-0.4.0/README.md000066400000000000000000000035101223100446700150270ustar00rootroot00000000000000PulseAudio system tray ====================== A replacement for the deprecated padevchooser Pasystray allows setting the default PulseAudio source/sink and moving streams on the fly between sources/sinks without restarting the client applications. Features -------- * switch default sink/source * move playback/record stream to different sink/source on the fly * detect pulseaudio instances on the network with avahi * set X property PULSE_SERVER (like padevchooser's "set default server") * adjust volume/toggle mute of sinks/sources and playback/record streams * rename devices Renaming devices needs module-device-manager to be loaded in pulseaudio. To detect remote sinks/sources you need to enable module-zeroconf-discover on the local PulseAudio instance and module-zeroconf-publish on the remote side. To control a different server than the local instance, run pasystray as: $ PULSE_SERVER=remote_host pasystray Mouse bindings -------------- over status icon: * middle-click: toggle mute default sink * ctrl + middle-click: toggle mute default source * scroll up/down: adjust the default sink volume * ctrl + scroll: adjust the default source volume over source/sink: * scroll up/down: adjust the volume of repsective stream * left-click: set as default sink/source * middle-click: toggle mute * right-click: open menu to rename source/sink over playback/record stream: * scroll up/down: adjust the volume of repsective stream * middle-click: toggle mute Troubleshooting --------------- If pasystray icon is not displayed in your Unity system tray, you will have to whitelist it. Read this for instructions: http://askubuntu.com/questions/30742/how-do-i-access-and-enable-more-icons-to-be-in-the-system-tray For ubuntu 13.04 and above, AppIndicator is mandatory. Unfortunatly, the ctrl-click/ctrl-scroll bindings don't work with AppIndicator. pasystray-0.4.0/TODO000066400000000000000000000006111223100446700142370ustar00rootroot00000000000000verify all mouse bindings works BUGS: mouse bindings, modifiers don't work with appindicator fix pulseaudio reconnect placement of device rename dialog close to systray FEATURES: debug output in release build (--debug) popup if can't rename device allow manual adding of servers module-device-manager autoload FUTURE: load avahi/notify support at runtime settings? gettext and translations pasystray-0.4.0/bootstrap.sh000077500000000000000000000002421223100446700161230ustar00rootroot00000000000000rm -rf autom4te.cache rm -f config.cache aclocal autoconf autoheader automake --add-missing CFLAGS="-g -O0 -DDEBUG" ./configure --sysconfdir=/etc "$@" make clean pasystray-0.4.0/configure.ac000066400000000000000000000112501223100446700160360ustar00rootroot00000000000000# This file is part of PaSystray # # Copyright (C) 2011, 2012 Christoph Gysin # # PaSystray is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # PaSystray is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with PaSystray; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. AC_PREREQ([2.68]) AC_INIT([pasystray], [0.4.0], [christoph.gysin@gmail.com], [pasystray], [http://github.com/christophgysin/pasystray]) AC_CONFIG_SRCDIR([src/pasystray.c]) AC_CONFIG_HEADERS([src/config.h]) AM_INIT_AUTOMAKE([foreign 1.9 -Wall]) AC_PROG_CC AM_PROG_CC_C_O ### check for gtk ############################################################# AC_ARG_WITH(gtk, AC_HELP_STRING([--with-gtk=2|3], [choose GTK version (default: 3)]),, with_gtk=3) AC_MSG_CHECKING([GTK version to use]) case ${with_gtk} in 2) GTK_VERSION=gtk+-2.0;; 3) GTK_VERSION=gtk+-3.0;; *) AC_MSG_ERROR([unknown GTK version!]);; esac AC_MSG_RESULT($GTK_VERSION) PKG_CHECK_MODULES(GTK, [ $GTK_VERSION ]) AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) ### check for pulseaudio libs ################################################# PKG_CHECK_MODULES(PULSEAUDIO, [ libpulse >= 1.0 libpulse-mainloop-glib >= 1.0 ]) AC_SUBST(PULSEAUDIO_CFLAGS) AC_SUBST(PULSEAUDIO_LIBS) ### optional avahi-client support ############################################# AC_ARG_ENABLE([avahi], AS_HELP_STRING([--disable-avahi], [Disable optional avahi support])) AS_IF([test "x$enable_avahi" != xno], [PKG_CHECK_MODULES(AVAHI, [ avahi-client >= 0.6 avahi-glib >= 0.6 ], HAVE_AVAHI=1, HAVE_AVAHI=0)], HAVE_AVAHI=0) AS_IF([test "x$enable_avahi" = xyes && test "x$HAVE_AVAHI" = x0], [AC_MSG_ERROR([*** avahi-client not found])]) AC_SUBST(AVAHI_CFLAGS) AC_SUBST(AVAHI_LIBS) AC_SUBST(HAVE_AVAHI) AM_CONDITIONAL([HAVE_AVAHI], [test "x$HAVE_AVAHI" = x1]) AS_IF([test "x$HAVE_AVAHI" = x1], AC_DEFINE([HAVE_AVAHI], 1, [Have avahi-client?])) ### optional libnotify support ################################################ AC_ARG_ENABLE([notify], AS_HELP_STRING([--disable-notify], [Disable optional libnotify support])) AS_IF([test "x$enable_notify" != xno], [PKG_CHECK_MODULES(NOTIFY, [ libnotify >= 0.7 ], HAVE_NOTIFY=1, HAVE_NOTIFY=0)], HAVE_NOTIFY=0) AS_IF([test "x$enable_notify" = xyes && test "x$HAVE_NOTIFY" = x0], [AC_MSG_ERROR([*** libnotify not found])]) AC_SUBST(NOTIFY_CFLAGS) AC_SUBST(NOTIFY_LIBS) AC_SUBST(HAVE_NOTIFY) AM_CONDITIONAL([HAVE_NOTIFY], [test "x$HAVE_NOTIFY" = x1]) AS_IF([test "x$HAVE_NOTIFY" = x1], AC_DEFINE([HAVE_NOTIFY], 1, [Have libnotify?])) ### optional Xlib support ###################################################### AC_ARG_ENABLE([x11], AS_HELP_STRING([--disable-x11], [Disable optional X11 support])) AS_IF([test "x$enable_x11" != xno], [PKG_CHECK_MODULES(X11, [ x11 >= 1.4 ], HAVE_X11=1, HAVE_X11=0)], HAVE_X11=0) AS_IF([test "x$enable_x11" = xyes && test "x$HAVE_X11" = x0], [AC_MSG_ERROR([*** libX11 not found])]) AC_SUBST(X11_CFLAGS) AC_SUBST(X11_LIBS) AC_SUBST(HAVE_X11) AM_CONDITIONAL([HAVE_X11], [test "x$HAVE_X11" = x1]) AS_IF([test "x$HAVE_X11" = x1], AC_DEFINE([HAVE_X11], 1, [Have X11?])) ### optional libappindicator support ########################################### AC_ARG_ENABLE([appindicator], AS_HELP_STRING([--disable-appindicator], [Disable optional appindicator support])) AS_IF([test "x$enable_appindicator" != xno], [PKG_CHECK_MODULES(APPINDICATOR, [ appindicator3-0.1 >= 12.10.0 ], HAVE_APPINDICATOR=1, HAVE_APPINDICATOR=0)], HAVE_APPINDICATOR=0) AS_IF([test "x$enable_appindicator" = xyes && test "x$HAVE_APPINDICATOR" = x0], [AC_MSG_ERROR([*** libappindicator not found])]) AC_SUBST(APPINDICATOR_CFLAGS) AC_SUBST(APPINDICATOR_LIBS) AC_SUBST(HAVE_APPINDICATOR) AM_CONDITIONAL([HAVE_APPINDICATOR], [test "x$HAVE_APPINDICATOR" = x1]) AS_IF([test "x$HAVE_APPINDICATOR" = x1], AC_DEFINE([HAVE_APPINDICATOR], 1, [Have APPINDICATOR?])) ################################################################################ if test "x$GCC" = xyes -o "x$CLANG" = xyes; then CFLAGS="$CFLAGS -pipe -Wall -W -Wno-unused-parameter" fi AC_CONFIG_FILES([Makefile src/Makefile]) AC_OUTPUT pasystray-0.4.0/data/000077500000000000000000000000001223100446700144625ustar00rootroot00000000000000pasystray-0.4.0/data/pasystray.desktop000066400000000000000000000003051223100446700201120ustar00rootroot00000000000000[Desktop Entry] Version=1.0 Name=PulseAudio System Tray GenericName= Comment=An Applet for PulseAudio Exec=pasystray Icon=pasystray StartupNotify=true Type=Application Categories=AudioVideo;Audio; pasystray-0.4.0/data/pasystray.png000066400000000000000000000311351223100446700172320ustar00rootroot00000000000000PNG  IHDR00%gAMA asRGB cHRMz&u0`:pQ<bKGDC pHYsZZp#}1IDATxͼgxDzYki)'$!I$!r6Lv l`1ƀ1$ & &"K$Hr\q~sܳ{?zfgTwuu?A@h@h@3pssd^>K6<0^_uT=i'G( 09S(wpz^{^36c~}72I!pH(j7x@Ž.@k 8Si:j[>ְӰ!i7uk*@gt7Mi3w$Zxm凕M6sI'.^Ђ ;S/QNTyKξD0>`d|L)NU1&LF506&ٔ[vZvZFq((gg>.;}=;.%/gtuw%f(QO p4|>Jݼx@! TUuDS29؄VL$*,|RK[4@CGJ0<%{˩SRFKY ̗T,Ir'rd'R*% ,ٖlK:JY>)}b)O5ڋ-;o;wec|Srhɀ5$>}\p W}u[-i2 (GB>2`r#zc&Ϛ,:n3O'eP֥tY2 {zLBDJ8H 2쀒 l)1Ji|- qR<`lvo 9|Ҙe+ASx2-A;,S;B]}]d o쿲e[hk+Wͯ_K{8u?;ho78#VPrXIF&"?Ba2$6^p#u )W.W+[AjI+ S 4f'ÁD^ La f@+| L0@Пr$In\@?ZulRPq>cn*ޕ(de7:8k؇4v#4e~7":V{3+އC pAډ+x4 ;. +_7:pc` d<2q!}$W@1uY8*gd<1q30 o B) >r-҄r9P%7Aih$;얟@(À,%9 wOEAMO7++5ccp䈩=xjvGZ#}#'%r6ȡ=o _WpRF>ѝq`\ ?`Y,-8|mC-rHVG,pR6rOdl6g %D503U1ǀkop`LpP64oof;t(J{yx*@)@CVls\F-hT0~j%mv3'󍊼>ˏfd4:q O@@(lI!F1yxo 3jt(ZeyrJ y~lH0|/@ ""Uzē=\) :hey!2 o԰?! (l0-q سm+*d6^ZB- QE>Is$^p$Ie h[Q`,2[¼¼j"wEOl7#d aJ = Yd˴=+K-'매JK "Enʗ{Y5rXӵ`a Ϯ?L O@7r2zW=^ $Y, 0W&̖cTcV1  +^ GKC^xPs"7.{q$6{@=d 2C/tr@H @ɏZ{0)h^^~'97 *U`uݪW'wIEd j:K??{ڭS)f\14zr,]w. Y-A4 b"J 17/OA~W"3 m% 6 0HorP_9<-P^jk/6 Hy~==V7wJt LyD ():HT# R!Aȗ<D,Miz6o"ګ#p$8W8bc ?SPlX>*W QB@:G;~Lc]'GBW(=Ι+sd W G2;WxH'J:p ŕ`J(H[e8.dHHo-`!J\xSݡS'q9`Poh (5n=WAz7=W?Y(ZsYځCBA| z: n->>׾ >|od bw@I͒%ϡbEr?MNֿyy༌Piux]!}vw>\sҷ>ugHpoz[˽r'0 l$$dܒ uWiXL_6Ѡ@z3iRU:\dmeY0ת$g>||lN쒙RB\%T߬/W{!>C,֦Vm!lz oO[@ @e)%T/_E>ff:H45W{/=XRK+@߮``|"1 ӈعގ-qZi7, {~9ޙA$ J_ |)˴,wπ \@<)b9%,Sx%ʭ=8ٳ-AEtIۂ9#PD;!AZ .uwOQw/8"n6!dklXWc ^5fG ?d 򦼩#魂Q1ٱʇ e]({]ԡTn 'i Oz&9^i6O2V:Z1">C//̏B̼19җ:׃LHxd% d4qoZ_>??LAu_n,0٧ [$?X-s.<c# riS}ZA=#Њ>%ӁR5 _T9@.`(C#q\qY ե8;sg g TST52 p@M!\%{~* Ovo]]V&j5r d0v]~k܀)°-WIc1ċă88@ZJI)r_%rIa}pp>qރOf:>烿 IKbA E_` O&CXSx+V JxC۵k#ԓm|Ld끌qe>)t׸oϯ<[{dz j-,ͭ M"s$9Dn6<5Tsy@ƀ5qŐQ9i%pX !.@o|V"T.zh$< [6_JappZ$<8̏O"B6gr@oK(+=NP']AMtr:ǃ]@-?[VDWD!e)G>`4ƚ-_;IubE Ojqsyh/Zߩb0Mʔ6`T^1>oNPі--{=|Y U[ճuێ`o3= rkmH[tPŖ(mL;hG jdo܂jF-̂som;~|)Er d%'f ҂[Xjߒ*/A:HW 0J@*iQxhݩb0f^ 5sVLw_oP #*gop9k9D{QoJ>/GU@Xp`@-vl-}]!ڶYk|Fm7V .y@Okc ܧxx.XV:#r!C΂d4cA|J8H]@w̬ZVZ/ug|ZzPE$(& dhF߉Jk5p .߸vْ޸;lSMA`(1dɞHpĶN#y>kjv7m 賥 x~  $)mUX;(]x0K`dXB;Dt7OƠc` /{R4d Ud?H$HG Ppʿ9RnG0 e-`.w] 2Ӵ*k^tr6f$^<7*[42~҉2X[#J<|v4qf\_qn?mjR(*Ņ/\qCVѻAF1ިQ~*!3@_3!|wH0G~uUگ ۀ̕*۽Mےy%BfX.hJߡoύv-b}Ix9Y{;ӑjSc%}7(3b_9cL T)30Mpd|L#PF|N4$*gU{nwt߆PP#0il}}>dY׸}K{l5ѫ[L!@yN(;]eW_rEoI!oנJa;!cir[@k-Nmjdlh<䑬uZ hsTuq`hu7x,Xeh9wL*z9,GI[NMAʔёTS^/3_<.0rl10GmSz u_G@'_eWR AT\&PeÀ-@ӁN\RP4|pC/!(KH0b 6-Bއ+n[b ~=iT+PQ*} \M2%x2[-Bq% 0v5_e:V-A~s,ǻZE 3e [@{_cXʷw屠P'Fa;Ӿ \>R0up:? {`LX)% \,ns<#׷ n+v` in{==wm pr:vc5h[j221R3C* DЀ6@d7׹trZ0 TKPTJM ,Ac ds9jڭjB3/%!Pqy; U{F u) } 2PoswbK H,7%X "Z-%;94.Kr2k $;7I`zC\c W}$@1}Zղ#mlq@&hW+.`&3Y[EQD!JQc.!97s~ Ngm@i˫9DP}5- ~\K9R*c?.#A@'L} e ڦ[VPc" F`;x %M@EV1U ja7mOVf#؋+ޗ~ .@47xem@p[@o ĪuWU@W (`|U6U)YVV/8=_d 0C-UhupDʶΌ>A:sbLHؒ˛􀜸Ԧwr\)ZFJ`/aUVK3d検Mx]Kl6SO+ѿH-zΰ8*l-@f$j鉹-jj@*s6489"ˀvRj 2M4iN#Ҁ*Q:VmPE:T,ޙw zuqփaqKCph=PQL϶@)c@Ic;mnsRD ΩDH9}X.&U=z>#4Se@֌j&Ssڧ>qH;.?h MCoos GL+c/Ak<ϋ~xe:E~e*Jmd[%< uHvU]uQ]4"TV"-\{OUK|`j9 e 2~ŶAK3$\u6yQ)ГT5\ g W vϡʮ{]c(>k0P[VՠRZ=8$^8!|&L %еV;Q p W;Ϋ`YȔ.g;ׅAO~>$}BHa,.~sU6kp=2v_Pփ~|3lYvi!}T QMzԓ` KN):4`K [oCـ«]-[q{Z2^WLU~5`&(^3 ȶުcvu8sw|}>AQEVqj\ߵ0{ߪ Q-|̐/XֱeuI;I6Al~8m2@xxT B%by0.^Ewhu)s`g0:FQW#S@[R'`U,/dcˢқ6XZVHH|~Xȷ1 ȡ93*5tHmw3xp=}RV#vR@dNN`c0Yk'f,V:^}Ss]w[ Kli++ a^ 7e*H_:yBӺsOAR,ݓo-3rs7)byKR,<_k`M+XJWv`CI3iF` KE-EQx&Xڤf{njYZr B?? `Bz{p4ɵ TzK:-K˚Rr?{G[mAnH=i9d' yi~rnrPj-A]#Sk GW'"XDpw7[ z5\!ݹz#q޼ Dޗ^`Q'F͉Y ,rGzDtݻׂjkӁ[Y7ޠn:js@vNRH<7 X:Ô "e-2hR~ <{p೪rȇ`j^Go<*5 y+}Aq`w\-ˁL,奟t,K?v/&Gv!RH+T,,,e,H䑴wc*Peߺ)N&; 6>eg6}!CPVxѬ&rXB*ץ1E_zKU@T ::?tO<JU<`J@s1AAW|=_h7U--i'r,a ԗ"5Y fVsAVv0 8@R?ˡRCFTʲᯃ7=ulk+\+4dL`2,o`PWZ?9K21?=F8%LwkӊJl Q ٸK6&I&Bd*H1sDKS(kT޺B3U<~ ~y VCOBU!aQFHӕ]VjfJL}L{zo߂N*P!ʪ5 ؁@*E\44hs TGG[8p2X` 7^gt#'iW@R~%cμC~݂wZ_LG]]=_!.!@iHWP-Ue 6աgᆜz`kgiUvx[0-r8!-8 w$8-#8$KP)*l/ UUW;BHNzNt_ >]29UC#ooW2+J{Mۿĝ8qQD jF1J;;,ݘLP_Mq9$ *~@dIɹ/=5o,71 8fPJǝA~o?l j JWSꀼgd_ABx[B@M|@\EmBA<)ђL Ƒ '00unWۦm(gy;\?iHt=9 *ZR}Cd!F5eTF5 5ƀ++0}LP{X)7Ss(C2Hs_` rr P=KT[ԟڹ=PۿM+Jqd{ǙAo7qڀNd$* ?ǀ,&0 Bd4!qphK)m\-(-@*C*IK % cD(1J&h5aDcq tlP2, f<H_-iz *JM?`jH6je6)7tF3|ş_;:gs@ T7?ЉwEZ`=:Nf i<ڮ`2D)k&$P|Do^n^5U " ^|>@N**\ r ۸,[A>,zܡp񴼶˓>GuBԋh1PS2=68m`|CRґ`XqH,Af2& Um 2i2ݤdONi |$mA4L*@ TJSiPo5@ŕW:prs}q%SKhTuUԚi #Imdh3~fծVk%<ePd,\Hr`4b*I2TOɗkbSbb%X  ĉ7H( }k,/4ٵAP +(QDEՠ-.`V  (H%PA';6nL1fJnP{>|h g00ٚM͹mOZVb_G9u"kAV*K[s{S[- rYH/AZJmQ@)'si)OA'5AH#VIɒ r_<h) U%SA @Hk_PrYr 7H-,  9 M$TQ/@]S5033}ANUC=D+J Q£57'}TaBj (?ͥ/}1M !Qk{CNG|(< \#]ǸngR''AD:HH{)pK& $ q0')A1cN0'R, / bi e@IC,Al+ #$X6EF |. M'?2xiw^yO<-u})N!/P_/՗/[|v_^ެe-[Glױes躑ڛZE0q9>/K(RY梜y7؀\Iw hpn9 B^p3\WH GYfcnpMv}, Swɰ.עE \K+ `W#8}-r앬+ٸ+JϿ.S_ƫcC%_x%|%}%?lQ3%tEXtdate:create2012-12-18T12:56:01+01:00.%tEXtdate:modify2012-12-18T12:56:01+01:00_ãEtEXtsvg:base-urifile:///home/chris/projects/pasystray/data/pasystray.svg=+IENDB`pasystray-0.4.0/data/pasystray.svg000066400000000000000000000255341223100446700172530ustar00rootroot00000000000000 image/svg+xml PulseAudio logotype 2006-08-28 Pierre Ossman <ossman@cendio.se> for Cendio AB Rafael Jannone (basic idea) pasystray-0.4.0/data/svg2png.sh000077500000000000000000000001331223100446700164040ustar00rootroot00000000000000convert \ -background none \ -resize 48x48 \ pasystray.svg \ pasystray.png pasystray-0.4.0/pkg/000077500000000000000000000000001223100446700143325ustar00rootroot00000000000000pasystray-0.4.0/pkg/arch/000077500000000000000000000000001223100446700152475ustar00rootroot00000000000000pasystray-0.4.0/pkg/arch/pasystray-git/000077500000000000000000000000001223100446700200675ustar00rootroot00000000000000pasystray-0.4.0/pkg/arch/pasystray-git/PKGBUILD000066400000000000000000000024741223100446700212220ustar00rootroot00000000000000# Maintainer: Christoph Gysin pkgname=pasystray-git pkgver=20130221 pkgrel=1 pkgdesc="PulseAudio system tray (a replacement for padevchooser)" arch=('i686' 'x86_64') url="https://github.com/christophgysin/pasystray" license=('LGPL') groups=('multimedia') depends=('libpulse' 'gtk3' 'libnotify' 'avahi' 'libx11' 'gnome-icon-theme') makedepends=('git' 'pkg-config') optdepends=( 'paman: Launch PulseAudio manager from tray icon' 'pavucontrol: Launch PulseAudio mixer from tray icon' 'pavumeter: Launch PulseAudio volume meter from tray icon' 'paprefs: Launch PulseAudio preferences from tray icon' ) provides=('pasystray') conflicts=('pasystray') replaces=('pasystray') backup=() options=() noextract=() md5sums=() _gitroot=git://github.com/christophgysin/${pkgname%-git}.git _gitname=${pkgname%-git} build() { cd "$srcdir" msg "Connecting to GIT server...." if [ -d $_gitname ] ; then cd $_gitname && git pull origin msg "The local files are updated." else git clone --depth=1 $_gitroot $_gitname fi msg "GIT checkout done or server timeout" cd "$srcdir/$_gitname" aclocal autoconf autoheader automake --add-missing ./configure --prefix=/usr } package() { cd "$srcdir/$_gitname" make DESTDIR="$pkgdir/" install } pasystray-0.4.0/pkg/arch/pasystray/000077500000000000000000000000001223100446700173065ustar00rootroot00000000000000pasystray-0.4.0/pkg/arch/pasystray/PKGBUILD000066400000000000000000000021121223100446700204260ustar00rootroot00000000000000# Maintainer: Christoph Gysin pkgname=pasystray pkgver=0.4.0 pkgrel=1 pkgdesc="PulseAudio system tray (a replacement for padevchooser)" arch=('i686' 'x86_64') url="https://github.com/christophgysin/pasystray" license=('LGPL') groups=('multimedia') depends=('libpulse' 'gtk3' 'libnotify' 'avahi' 'libx11' 'gnome-icon-theme') makedepends=('automake' 'autoconf') optdepends=( 'paman: Launch PulseAudio manager from tray icon' 'pavucontrol: Launch PulseAudio mixer from tray icon' 'pavumeter: Launch PulseAudio volume meter from tray icon' 'paprefs: Launch PulseAudio preferences from tray icon' ) provides=('pasystray') conflicts=('pasystray') replaces=('pasystray') source=("https://github.com/christophgysin/${pkgname}/archive/${pkgname}-${pkgver}.tar.gz") md5sums=('a86dc07ea580df90208d312ca67827b7') build() { cd $srcdir/$pkgname-$pkgname-$pkgver aclocal autoconf autoheader automake --add-missing ./configure --prefix=/usr make } package() { cd $srcdir/$pkgname-$pkgname-$pkgver make DESTDIR="$pkgdir/" install } pasystray-0.4.0/pkg/debian/000077500000000000000000000000001223100446700155545ustar00rootroot00000000000000pasystray-0.4.0/pkg/debian/changelog000066400000000000000000000037661223100446700174420ustar00rootroot00000000000000pasystray (0.3.0-1) quantal; urgency=low * update to 0.3.0 -- Christoph Gysin Thu, 16 May 2013 21:22:20 +0100 pasystray (0.2.3-1) quantal; urgency=low * update to 0.2.3 -- Christoph Gysin Thu, 21 Feb 2013 23:03:20 +0100 pasystray (0.2.2-1) quantal; urgency=low * update to 0.2.2 -- Christoph Gysin Tue, 18 Dec 2012 17:26:20 +0100 pasystray (0.2.1-3) quantal; urgency=low * build for quantal -- Christoph Gysin Mon, 03 Dec 2012 23:35:18 +0200 pasystray (0.2.1-2) precise; urgency=low * build for precise -- Christoph Gysin Sat, 12 May 2012 02:38:10 +0200 pasystray (0.2.1-1) oneiric; urgency=low * update to 0.2.1, fix tarball contents -- Christoph Gysin Tue, 17 Apr 2012 10:45:28 +0200 pasystray (0.2.0-1) oneiric; urgency=low * update to 0.2.0, add avahi/notify dependency -- Christoph Gysin Mon, 17 Apr 2012 00:27:08 +0200 pasystray (0.1.1-5) oneiric; urgency=low * fix runtime dependencies (libgtk-3-0, pulseaudio) -- Christoph Gysin Thu, 02 Dec 2011 11:46:08 +0200 pasystray (0.1.1-4) oneiric; urgency=low * fix build dependencies (gtk3, pulseaudio) -- Christoph Gysin Thu, 02 Dec 2011 10:55:30 +0200 pasystray (0.1.1-3) oneiric; urgency=low * fix build dependencies (gtk3, pulseaudio) -- Christoph Gysin Thu, 02 Dec 2011 10:50:30 +0200 pasystray (0.1.1-2) oneiric; urgency=low * fix build dependencies -- Christoph Gysin Thu, 02 Dec 2011 10:35:43 +0200 pasystray (0.1.1-1) oneiric; urgency=low * recreate source package -- Christoph Gysin Thu, 02 Dec 2011 10:02:13 +0200 pasystray (0.1-1) oneiric; urgency=low * Initial release -- Christoph Gysin Thu, 01 Dec 2011 21:08:36 +0200 pasystray-0.4.0/pkg/debian/compat000066400000000000000000000000021223100446700167520ustar00rootroot000000000000008 pasystray-0.4.0/pkg/debian/control000066400000000000000000000016341223100446700171630ustar00rootroot00000000000000Source: pasystray Section: sound Priority: extra Maintainer: Christoph Gysin Build-Depends: debhelper (>= 8.0.0), autotools-dev, pkg-config, libgtk-3-dev, libpulse-dev, libavahi-client-dev, libavahi-glib-dev, libnotify-dev, libappindicator3-dev Standards-Version: 3.9.3 Homepage: http://github.com/christophgysin/pasystray Vcs-Git: git://github.com/christophgysin/pasystray.git Vcs-Browser: http://github.com/christophgysin/pasystray Package: pasystray Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libgtk-3-0, libpulse0, libavahi-client3, libavahi-glib1, libnotify4, gnome-icon-theme-full, libappindicator3-1 Description: PulseAudio system tray - a padevchooser replacement PaSystray provides a system tray icon to control the PulseAudio daemon. It supports changing the default source/sink, detecting remote source/sinks and moving streams to other souce/sinks on the fly. pasystray-0.4.0/pkg/debian/copyright000066400000000000000000000023061223100446700175100ustar00rootroot00000000000000Format: http://dep.debian.net/deps/dep5 Upstream-Name: pasystray Source: http://github.com/christophgysin/pasystray Files: * Copyright: 2011 Christoph Gysin License: LGPL-2.0+ Files: debian/* Copyright: 2011 Christoph Gysin License: LGPL-2.0+ License: LGPL-2.0+ This package is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. . This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. . You should have received a copy of the GNU General Public License along with this program. If not, see . . On Debian systems, the complete text of the GNU Lesser General Public License can be found in "/usr/share/common-licenses/LGPL-2". # Please also look if there are files or directories which have a # different copyright/license attached and list them here. pasystray-0.4.0/pkg/debian/docs000066400000000000000000000000171223100446700164250ustar00rootroot00000000000000README.md TODO pasystray-0.4.0/pkg/debian/rules000077500000000000000000000006721223100446700166410ustar00rootroot00000000000000#!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # This file was originally written by Joey Hess and Craig Small. # As a special exception, when this file is copied by dh-make into a # dh-make output file, you may use that output file without restriction. # This special exception was added by Craig Small in version 0.37 of dh-make. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 %: dh $@ pasystray-0.4.0/pkg/debian/source/000077500000000000000000000000001223100446700170545ustar00rootroot00000000000000pasystray-0.4.0/pkg/debian/source/format000066400000000000000000000000141223100446700202620ustar00rootroot000000000000003.0 (quilt) pasystray-0.4.0/pkg/gentoo/000077500000000000000000000000001223100446700156255ustar00rootroot00000000000000pasystray-0.4.0/pkg/gentoo/pasystray-0.3.0.ebuild000066400000000000000000000015571223100446700215160ustar00rootroot00000000000000# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header$ EAPI=4 inherit gnome2-utils autotools DESCRIPTION="PulseAudio system tray (replacement for padevchooser)" HOMEPAGE="http://github.com/christophgysin/pasystray" SRC_URI="https://github.com/christophgysin/${PN}/archive/${PV}.tar.gz" LICENSE="LGPL-2.1" SLOT="0" KEYWORDS="~amd64 ~x86" IUSE="libnotify" RDEPEND=">=media-sound/pulseaudio-1.0[glib,avahi] >=net-dns/avahi-0.6 x11-libs/gtk+:3 x11-libs/libX11 libnotify? ( >=x11-libs/libnotify-0.7 )" DEPEND="${RDEPEND} virtual/pkgconfig" DOCS="AUTHORS README.md TODO" src_prepare() { eautoreconf } src_configure() { econf $(use_enable libnotify notify) } pkg_preinst() { gnome2_icon_savelist; } pkg_postinst() { gnome2_icon_cache_update; } pkg_postrm() { gnome2_icon_cache_update; } pasystray-0.4.0/pkg/gentoo/pasystray-9999.ebuild000066400000000000000000000016001223100446700214700ustar00rootroot00000000000000# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header$ EAPI=4 inherit eutils gnome2-utils git-2 autotools DESCRIPTION="PulseAudio system tray (replacement for padevchooser)" HOMEPAGE="http://github.com/christophgysin/pasystray" EGIT_REPO_URI="git://github.com/christophgysin/${PN}" LICENSE="LGPL-2.1" SLOT="0" KEYWORDS="" IUSE="libnotify" RDEPEND=">=media-sound/pulseaudio-1.0[glib,avahi] >=net-dns/avahi-0.6 x11-libs/gtk+:3 x11-libs/libX11 x11-themes/gnome-icon-theme libnotify? ( >=x11-libs/libnotify-0.7 )" DEPEND="${RDEPEND} virtual/pkgconfig" DOCS="AUTHORS README.md TODO" src_prepare() { eautoreconf } src_configure() { econf $(use_enable libnotify notify) } pkg_preinst() { gnome2_icon_savelist; } pkg_postinst() { gnome2_icon_cache_update; } pkg_postrm() { gnome2_icon_cache_update; } pasystray-0.4.0/src/000077500000000000000000000000001223100446700143405ustar00rootroot00000000000000pasystray-0.4.0/src/Makefile.am000066400000000000000000000033541223100446700164010ustar00rootroot00000000000000# This file is part of PaSystray # # Copyright (C) 2011, 2012 Christoph Gysin # # PaSystray is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # PaSystray is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with PaSystray; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. gladedir = $(pkgdatadir) bin_PROGRAMS = pasystray glade_DATA = pasystray.glade pasystray_SOURCES = \ avahi.c \ avahi.h \ menu_info.c \ menu_info.h \ notify.c \ notify.h \ options.c \ options.h \ pasystray.c \ pasystray.h \ pulseaudio.c \ pulseaudio.h \ pulseaudio_action.c \ pulseaudio_action.h \ pulseaudio_info.c \ pulseaudio_info.h \ systray.c \ systray.h \ systray_impl.c \ systray_impl.h \ ui.c \ ui.h \ x11-property.c \ x11-property.h pasystray_LDADD = \ $(AM_LDADD) \ $(GTK_LIBS) \ $(PULSEAUDIO_LIBS) \ $(NOTIFY_LIBS) \ $(AVAHI_LIBS) \ $(APPINDICATOR_LIBS) \ $(X11_LIBS) pasystray_CFLAGS = \ $(AM_CFLAGS) \ $(GTK_CFLAGS) \ $(PULSEAUDIO_CFLAGS) \ $(NOTIFY_CFLAGS) \ $(AVAHI_CFLAGS) \ $(APPINDICATOR_CFLAGS) \ $(X11_CFLAGS) \ -DGLADE_FILE=\"$(gladedir)/pasystray.glade\" EXTRA_DIST = \ $(glade_DATA) pasystray-0.4.0/src/avahi.c000066400000000000000000000176471223100446700156130ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #include "config.h" #ifndef HAVE_AVAHI #include "avahi.h" void avahi_init(GMainLoop* loop){} void avahi_start(menu_infos_t* mis){} void avahi_destroy(){} #else #include #include #include #include #include #include "avahi.h" static const char* AVAHI_SERVICE_PULSEAUDIO_SERVER_TCP = "_pulse-server._tcp"; static AvahiGLibPoll* glib_poll = NULL; static const AvahiPoll* poll_api = NULL; static AvahiClient* client = NULL; static AvahiServiceBrowser* sb = NULL; static void avahi_client_callback(AvahiClient* c, AvahiClientState state, void* userdata); static void avahi_browse_callback(AvahiServiceBrowser* b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char* name, const char* type, const char* domain, AvahiLookupResultFlags flags, void* userdata); static void avahi_resolve_callback(AvahiServiceResolver* r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char* name, const char* type, const char* domain, const char* host_name, const AvahiAddress* address, uint16_t port, AvahiStringList* txt, AvahiLookupResultFlags flags, void* userdata); static void avahi_server_add(menu_info_t* mi, const char* name, const AvahiAddress* address, uint16_t port, AvahiStringList* txt); static void avahi_server_remove(menu_info_t* mi, const char* name); void avahi_init(GMainLoop* loop) { avahi_set_allocator(avahi_glib_allocator()); glib_poll = avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT); if(glib_poll == NULL) { g_warning("Failed to create Avahi glib poll object."); return; } poll_api = avahi_glib_poll_get(glib_poll); int error; client = avahi_client_new(poll_api, 0, avahi_client_callback, loop, &error); if(client == NULL) { g_warning("Error initializing Avahi: %s", avahi_strerror(error)); return; } #ifdef DEBUG const char* version = avahi_client_get_version_string(client); if(version == NULL) { g_warning("Error getting version string: %s", avahi_strerror(avahi_client_errno(client))); return; } g_message("Avahi Server Version: %s", version); #endif } void avahi_start(menu_infos_t* mis) { if(!client) return; sb = avahi_service_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_SERVICE_PULSEAUDIO_SERVER_TCP, NULL, 0, avahi_browse_callback, mis); if(!sb) g_message("Failed to create service browser: %s", avahi_strerror(avahi_client_errno(client))); } void avahi_destroy() { if(sb) avahi_service_browser_free(sb); if(client) avahi_client_free(client); if(glib_poll) avahi_glib_poll_free(glib_poll); } static void avahi_client_callback(AvahiClient* c, AvahiClientState state, void* userdata) { assert(c); if(state == AVAHI_CLIENT_FAILURE) g_message("Server connection failure: %s", avahi_strerror(avahi_client_errno(c))); } static void avahi_browse_callback(AvahiServiceBrowser* b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char* name, const char* type, const char* domain, AvahiLookupResultFlags flags, void* userdata) { assert(b); menu_infos_t* mis = userdata; switch (event) { case AVAHI_BROWSER_FAILURE: g_message("[avahi] %s", avahi_strerror(avahi_client_errno( avahi_service_browser_get_client(b)))); return; case AVAHI_BROWSER_NEW: #ifdef DEBUG g_message("[avahi] new service '%s' of type '%s' in domain '%s'", name, type, domain); #endif /* We ignore the returned resolver object. In the callback function we free it. If the server is terminated before the callback function is called the server will free the resolver for us. */ if (!(avahi_service_resolver_new( client, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, avahi_resolve_callback, userdata))) g_message("Failed to resolve service '%s': %s", name, avahi_strerror(avahi_client_errno(client))); break; case AVAHI_BROWSER_REMOVE: avahi_server_remove(&mis->menu_info[MENU_SERVER], name); break; case AVAHI_BROWSER_ALL_FOR_NOW: case AVAHI_BROWSER_CACHE_EXHAUSTED: break; } } char* avahi_string_list_info(AvahiStringList* list) { char* str = NULL; char* key = NULL; char* value = NULL; while(list) { avahi_string_list_get_pair(list, &key, &value, NULL); char* new = g_strdup_printf("%s%s%s: %s", str ? str : "", str ? "\n" : "", key, value); avahi_free(key); avahi_free(value); g_free(str); str = new; list = avahi_string_list_get_next(list); } return str; } static void avahi_resolve_callback(AvahiServiceResolver* r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char* name, const char* type, const char* domain, const char* host_name, const AvahiAddress* address, uint16_t port, AvahiStringList* txt, AvahiLookupResultFlags flags, void* userdata) { assert(r); menu_infos_t* mis = userdata; switch (event) { case AVAHI_RESOLVER_FAILURE: g_message("[avahi] Failed to resolve service '%s' of type '%s' in domain '%s': %s", name, type, domain, avahi_strerror(avahi_client_errno( avahi_service_resolver_get_client(r)))); break; case AVAHI_RESOLVER_FOUND: avahi_server_add(&mis->menu_info[MENU_SERVER], name, address, port, txt); break; } avahi_service_resolver_free(r); } void avahi_server_add(menu_info_t* mi, const char* name, const AvahiAddress* address, uint16_t port, AvahiStringList* txt) { char a[AVAHI_ADDRESS_STR_MAX]; avahi_address_snprint(a, sizeof(a), address); gchar* host_port = g_strdup_printf("%s:%u", a, port); #ifdef DEBUG g_message("[avahi] new server detected: %s %s", name, host_port); #endif char* text = avahi_string_list_info(txt); // TODO: tooltip formatting gchar* tooltip = g_strdup_printf( "name: %s\n" "host: %s\n" "%s", name, host_port, text); // remove any existing entry detected from X property menu_info_item_t* mii = menu_info_item_get_by_desc(mi, host_port); if(mii) menu_info_item_remove_by_name(mi, mii->name); menu_info_item_update(mi, -1, name, name, NULL, 0, tooltip, NULL, host_port, -1); g_free(tooltip); avahi_free(text); g_free(host_port); } void avahi_server_remove(menu_info_t* mi, const char* name) { #ifdef DEBUG g_message("[avahi] remove server '%s'", name); #endif menu_info_item_remove_by_name(mi, name); } #endif pasystray-0.4.0/src/avahi.h000066400000000000000000000017671223100446700156140ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #ifndef PASYSTRAY_AVAHI_H #define PASYSTRAY_AVAHI_H #include #include "menu_info.h" void avahi_init(GMainLoop* loop); void avahi_start(menu_infos_t* mis); void avahi_destroy(); #endif /* PASYSTRAY_AVAHI_H */ pasystray-0.4.0/src/menu_info.c000066400000000000000000000403621223100446700164700ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #include #include "menu_info.h" #include "systray.h" #include "pulseaudio_action.h" #include "ui.h" #include "x11-property.h" menu_infos_t* menu_infos_create() { menu_infos_t* mis = g_new(menu_infos_t, 1); size_t i; for(i=0; imenu_info[i], i); return mis; } void menu_infos_init(menu_infos_t* mis) { menu_info_t* servers = &mis->menu_info[MENU_SERVER]; servers->default_name = x11_property_get("PULSE_SERVER"); if(servers->default_name) menu_info_item_update(servers, -1, servers->default_name, servers->default_name, NULL, 0, "detected in X properties", NULL, servers->default_name, -1); } void menu_infos_clear(menu_infos_t* mis) { size_t i; for(i=0; imenu_info[i]; GHashTableIter iter; gpointer key; menu_info_item_t* mii; g_hash_table_iter_init(&iter, mi->items); while(g_hash_table_iter_next(&iter, &key, (gpointer*)&mii)) { switch(mi->type) { case MENU_SERVER: case MENU_SINK: case MENU_SOURCE: systray_remove_radio_item(mi, mii->widget); break; case MENU_INPUT: case MENU_OUTPUT: systray_remove_menu_item(mi, mii->widget); break; } g_hash_table_iter_remove(&iter); } mis->menu_info[i].group = NULL; } } void menu_infos_destroy(menu_infos_t* mis) { size_t i; for(i=0; imenu_info[i]); g_free(mis); } menu_info_t* menu_info_create(menu_infos_t* mis, menu_type_t type) { menu_info_t* mi = g_new(menu_info_t, 1); menu_info_init(mis, mi, type); return mi; } void menu_info_init(menu_infos_t* mis, menu_info_t* mi, menu_type_t type) { mi->type = type; mi->menu = NULL; mi->group = NULL; GHashFunc hash_func = g_direct_hash; GEqualFunc eq_func = g_direct_equal; if(type == MENU_SERVER) { hash_func = g_str_hash; eq_func = g_str_equal; } mi->items = g_hash_table_new_full(hash_func, eq_func, NULL, (GDestroyNotify) menu_info_item_destroy); mi->menu_infos = mis; mi->parent = NULL; mi->default_name = NULL; } void menu_info_destroy(menu_info_t* mi) { g_hash_table_destroy(mi->items); g_free(mi->default_name); } void menu_info_item_init(menu_info_item_t* mii) { mii->name = NULL; mii->desc = NULL; mii->volume = NULL; mii->notify = NULL; mii->icon = NULL; mii->widget = NULL; mii->menu_info = NULL; mii->submenu = NULL; mii->context = NULL; mii->address = NULL; } void menu_info_item_destroy(menu_info_item_t* mii) { g_free(mii->name); g_free(mii->desc); g_free(mii->volume); g_free(mii->icon); g_free(mii->address); g_free(mii); } const char* menu_info_type_name(menu_type_t type) { static const char* MENU_NAME[] = { [MENU_SERVER] = "server", [MENU_SINK] = "sink", [MENU_SOURCE] = "source", [MENU_INPUT] = "input", [MENU_OUTPUT] = "output", }; return MENU_NAME[type]; } menu_type_t menu_info_submenu_type(menu_type_t menu_type) { switch(menu_type) { case MENU_SINK: return MENU_INPUT; case MENU_SOURCE: return MENU_OUTPUT; case MENU_INPUT: return MENU_SINK; case MENU_OUTPUT: return MENU_SOURCE; default: break; } return -1; } void menu_info_item_update(menu_info_t* mi, uint32_t index, const char* name, const char* desc, const pa_cvolume* vol, int mute, char* tooltip, const char* icon, const char* address, uint32_t target) { menu_info_item_t* item; if(mi->type == MENU_SERVER) item = menu_info_item_get_by_name(mi, name); else item = menu_info_item_get(mi, index); if(item == NULL) return menu_info_item_add(mi, index, name, desc, vol, mute, tooltip, icon, address, target); #ifdef DEBUG g_message("[menu_info] updating %s %u %s (target: %d)", menu_info_type_name(item->menu_info->type), index, desc, (int)target); #endif g_free(item->name); item->name = g_strdup(name); g_free(item->desc); item->desc = g_strdup(desc); g_free(item->volume); item->volume = g_memdup(vol, sizeof(pa_cvolume)); item->mute = mute; item->target = target; g_free(item->address); item->address = g_strdup(address); menu_type_t submenu_type = menu_info_submenu_type(mi->type); menu_info_t* submenu = NULL; if(submenu_type != (menu_type_t)-1) submenu = &mi->menu_infos->menu_info[submenu_type]; gtk_menu_item_set_label(GTK_MENU_ITEM(item->widget), desc); systray_set_tooltip(GTK_WIDGET(item->widget), tooltip); switch(mi->type) { case MENU_SERVER: break; case MENU_SINK: case MENU_SOURCE: systray_update_item_in_all_submenus(item, submenu); break; case MENU_INPUT: case MENU_OUTPUT: systray_update_all_items_in_submenu(submenu, item); break; } /* if this is the default sink, update status icon acording to volume */ if(mi->type == MENU_SINK && item == menu_info_item_get_by_name(mi, mi->default_name)) ui_update_systray_icon(item); } void menu_info_item_add(menu_info_t* mi, uint32_t index, const char* name, const char* desc, const pa_cvolume* vol, int mute, char* tooltip, const char* icon, const char* address, uint32_t target) { menu_infos_t* mis = mi->menu_infos; menu_info_item_t* item = g_new(menu_info_item_t, 1); menu_info_item_init(item); item->menu_info = mi; #ifdef DEBUG g_message("[menu_info] adding %s %u %s (target: %d)", menu_info_type_name(mi->type), index, desc, (int)target); #endif item->index = index; item->name = g_strdup(name); item->desc = g_strdup(desc); item->volume = g_memdup(vol, sizeof(pa_cvolume)); item->target = target; item->mute = mute; item->icon = g_strdup(icon); item->address = g_strdup(address); menu_type_t submenu_type = menu_info_submenu_type(mi->type); menu_info_t* submenu = &mis->menu_info[submenu_type]; switch(item->menu_info->type) { case MENU_INPUT: case MENU_OUTPUT: item->submenu = menu_info_create(mis, submenu_type); item->submenu->parent = item; break; default: break; } switch(mi->type) { case MENU_SERVER: item->widget = systray_add_radio_item(mi, desc, tooltip); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item->widget), (item->address == mi->default_name) || (item->address && mi->default_name && g_str_equal(mi->default_name, item->address))); break; case MENU_SINK: case MENU_SOURCE: item->context = menu_info_item_context_menu(item); item->widget = systray_add_radio_item(mi, desc, tooltip); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item->widget), g_str_equal(mi->default_name, item->name)); systray_add_item_to_all_submenus(item, submenu); break; case MENU_INPUT: case MENU_OUTPUT: item->widget = systray_menu_add_submenu(mi->menu, item->submenu, desc, tooltip, icon); systray_add_all_items_to_submenu(submenu, item); break; } g_signal_connect(item->widget, "button-press-event", G_CALLBACK(menu_info_item_clicked), item); gtk_widget_add_events(item->widget, GDK_SCROLL_MASK); g_signal_connect(item->widget, "scroll-event", G_CALLBACK(menu_info_item_scrolled), item); if(mi->type == MENU_SERVER) g_hash_table_insert(mi->items, item->name, item); else g_hash_table_insert(mi->items, GUINT_TO_POINTER(index), item); /* if this is the default sink, update status icon acording to volume */ if(mi->type == MENU_SINK && item == menu_info_item_get_by_name(mi, mi->default_name)) ui_update_systray_icon(item); } GtkMenuShell* menu_info_item_context_menu(menu_info_item_t* mii) { GtkMenuShell* menu = GTK_MENU_SHELL(gtk_menu_new()); GtkWidget* item = gtk_menu_item_new_with_label("rename"); g_signal_connect(item, "button-press-event", G_CALLBACK(menu_info_item_rename_dialog), mii); gtk_menu_shell_append(menu, item); gtk_widget_show_all(GTK_WIDGET(menu)); return menu; } void menu_info_subitem_add(menu_info_t* mi, uint32_t index, const char* name, const char* desc, char* tooltip, const char* icon) { menu_info_item_t* subitem = g_new(menu_info_item_t, 1); menu_info_item_init(subitem); subitem->index = index; subitem->name = g_strdup(name); subitem->desc = g_strdup(desc); subitem->menu_info = mi; subitem->widget = systray_add_radio_item(mi, desc, tooltip); gboolean active = mi->parent->target == index; gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(subitem->widget), active); #ifdef DEBUG g_message("[menu_info] adding subitem %s %u '%s' %s", menu_info_type_name(mi->type), index, desc, active ? " (active)" : ""); #endif g_hash_table_insert(mi->items, GUINT_TO_POINTER(index), subitem); g_signal_connect(subitem->widget, "button-press-event", G_CALLBACK(menu_info_subitem_clicked), subitem); } void menu_info_subitem_update(menu_info_t* mi, uint32_t index, const char* name, const char* desc, char* tooltip, const char* icon) { menu_info_item_t* item = menu_info_item_get(mi, index); if(item == NULL) g_error("[menu_info] subitem not found!"); gboolean active = mi->parent->target == index; #ifdef DEBUG g_message("[menu_info] updating subitem %s %u '%s' %s", menu_info_type_name(mi->type), index, desc, active ? " (active)" : ""); #endif if(!g_str_equal(item->desc, desc)) gtk_menu_item_set_label(GTK_MENU_ITEM(item->widget), desc); if(active) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item->widget), TRUE); } menu_info_item_t* menu_info_item_get(menu_info_t* mi, uint32_t index) { return g_hash_table_lookup(mi->items, GUINT_TO_POINTER(index)); } gboolean name_equal(gpointer key, gpointer value, gpointer user_data) { menu_info_item_t* mii = value; const char* name = user_data; return g_str_equal(mii->name, name); } menu_info_item_t* menu_info_item_get_by_name(menu_info_t* mi, const char* name) { return g_hash_table_find(mi->items, name_equal, (gpointer)name); } gboolean desc_equal(gpointer key, gpointer value, gpointer user_data) { menu_info_item_t* mii = value; const char* desc = user_data; return g_str_equal(mii->desc, desc); } menu_info_item_t* menu_info_item_get_by_desc(menu_info_t* mi, const char* desc) { return g_hash_table_find(mi->items, desc_equal, (gpointer)desc); } void menu_info_item_clicked(GtkWidget* item, GdkEventButton* event, menu_info_item_t* mii) { #ifdef DEBUG g_message("[systray] button-press-event mod:%s button:%i", (event->state & GDK_CONTROL_MASK) ? "ctrl" : "", event->button); #endif switch(event->button) { /* on left-click, set device as default */ case 1: pulseaudio_set_default(mii); break; /* on middle-click, toggle mute device/stream */ case 2: pulseaudio_toggle_mute(mii); break; /* on right-click, show context menu (if any) */ case 3: if(mii->context) gtk_menu_popup(GTK_MENU(mii->context), NULL, NULL, NULL, NULL, (event != NULL) ? event->button : 0, gdk_event_get_time((GdkEvent*)event)); break; } } void menu_info_item_scrolled(GtkWidget* item, GdkEventScroll* event, menu_info_item_t* mii) { #ifdef DEBUG g_message("[systray] scroll-event mod:%s dir:%s", (event->state & GDK_CONTROL_MASK) ? "ctrl" : "", (event->direction == GDK_SCROLL_UP) ? "up" : (event->direction == GDK_SCROLL_DOWN) ? "down" : (event->direction == GDK_SCROLL_LEFT) ? "left" : (event->direction == GDK_SCROLL_RIGHT) ? "right" : "???"); #endif int inc = 0; switch(event->direction) { case GDK_SCROLL_UP: inc = 1; break; case GDK_SCROLL_DOWN: inc = -1; break; default: return; } switch(mii->menu_info->type) { case MENU_SERVER: break; case MENU_SINK: case MENU_SOURCE: case MENU_INPUT: case MENU_OUTPUT: pulseaudio_volume(mii, inc); break; } } void menu_info_subitem_clicked(GtkWidget* item, GdkEvent* event, menu_info_item_t* mii) { #ifdef DEBUG g_message("move %s %s to %s %s", menu_info_type_name(mii->menu_info->parent->menu_info->type), mii->menu_info->parent->desc, menu_info_type_name(mii->menu_info->type), mii->desc); #endif switch(mii->menu_info->type) { case MENU_SERVER: break; case MENU_SINK: pulseaudio_move_input_to_sink(mii->menu_info->parent, mii); break; case MENU_SOURCE: pulseaudio_move_output_to_source(mii->menu_info->parent, mii); break; case MENU_INPUT: case MENU_OUTPUT: break; } } void menu_info_item_rename_dialog(GtkWidget* item, GdkEventButton* event, menu_info_item_t* mii) { gtk_menu_popdown(GTK_MENU(mii->menu_info->menu_infos->menu)); char* title = g_strdup_printf("Rename %s %s", menu_info_type_name(mii->menu_info->type), mii->desc); char* text = g_strdup_printf("%s to:", title); GtkDialog* dialog = ui_renamedialog(); gtk_window_set_title(GTK_WINDOW(dialog), title); gtk_label_set_text(ui_renamedialog_label(), text); gtk_entry_set_text(ui_renamedialog_entry(), mii->desc); g_free(text); g_free(title); gtk_widget_show_all(GTK_WIDGET(dialog)); if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { const char* entry = gtk_entry_get_text(GTK_ENTRY(ui_renamedialog_entry())); char* name = g_strstrip(g_strdup(entry)); if(!g_str_equal(name, mii->desc)) pulseaudio_rename(mii, name); g_free(name); } gtk_widget_hide(GTK_WIDGET(dialog)); } void menu_info_item_remove(menu_info_t* mi, uint32_t index) { menu_info_item_t* mii = menu_info_item_get(mi, index); if(!mii) return; #ifdef DEBUG g_message("[menu_info] removing %s %u", menu_info_type_name(mi->type), index); #endif systray_remove_item(mii); g_hash_table_remove(mi->items, GUINT_TO_POINTER(index)); } void menu_info_item_remove_by_name(menu_info_t* mi, const char* name) { menu_info_item_t* mii = menu_info_item_get_by_name(mi, name); if(!mii) { g_warning("failed to remove %s '%s': item not found!", menu_info_type_name(mi->type), name); return; } #ifdef DEBUG g_message("[menu_info] removing %s %s (by name: '%s')", menu_info_type_name(mi->type), mii->desc, name); #endif systray_remove_item(mii); g_hash_table_foreach_remove(mi->items, name_equal, mii->name); } pasystray-0.4.0/src/menu_info.h000066400000000000000000000077011223100446700164750ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #ifndef PASYSTRAY_MENU_INFO_H #define PASYSTRAY_MENU_INFO_H #include #include #include #include "notify.h" typedef void* systray_t; typedef enum { MENU_SERVER = 0, MENU_SINK = 1, MENU_SOURCE = 2, MENU_INPUT = 3, MENU_OUTPUT = 4, } menu_type_t; enum { MENU_COUNT = 5 }; typedef struct menu_infos_t_ menu_infos_t; typedef struct menu_info_t_ menu_info_t; typedef struct menu_info_item_t_ menu_info_item_t; struct menu_info_t_ { menu_type_t type; GtkMenuShell* menu; GSList* group; GHashTable* items; menu_infos_t* menu_infos; menu_info_item_t* parent; char* default_name; }; struct menu_infos_t_ { systray_t systray; GtkMenuShell* menu; menu_info_t menu_info[MENU_COUNT]; }; struct menu_info_item_t_ { uint32_t index; char* name; char* desc; char* address; pa_cvolume* volume; notify_handle_t notify; int mute; uint32_t target; char* icon; GtkWidget* widget; menu_info_t* menu_info; menu_info_t* submenu; GtkMenuShell* context; }; menu_infos_t* menu_infos_create(); void menu_infos_init(menu_infos_t* mis); void menu_infos_clear(menu_infos_t* mis); void menu_infos_destroy(menu_infos_t* mis); menu_info_t* menu_info_create(menu_infos_t* mis, menu_type_t type); void menu_info_init(menu_infos_t* mis, menu_info_t* mi, menu_type_t type); void menu_info_destroy(menu_info_t* mi); void menu_info_item_init(menu_info_item_t* mii); void menu_info_item_destroy(menu_info_item_t* mii); const char* menu_info_type_name(menu_type_t type); menu_type_t menu_info_submenu_type(menu_type_t menu_type); void menu_info_item_add(menu_info_t* mi, uint32_t index, const char* name, const char* desc, const pa_cvolume* vol, int mute, char* tooltip, const char* icon, const char* address, uint32_t target); void menu_info_item_update(menu_info_t* mi, uint32_t index, const char* name, const char* desc, const pa_cvolume* vol, int mute, char* tooltip, const char* icon, const char* address, uint32_t target); GtkMenuShell* menu_info_item_context_menu(menu_info_item_t* mii); void menu_info_subitem_add(menu_info_t* mi, uint32_t index, const char* name, const char* desc, char* tooltip, const char* icon); void menu_info_subitem_update(menu_info_t* mi, uint32_t index, const char* name, const char* desc, char* tooltip, const char* icon); menu_info_item_t* menu_info_item_get(menu_info_t* mi, uint32_t index); menu_info_item_t* menu_info_item_get_by_name(menu_info_t* mi, const char* name); menu_info_item_t* menu_info_item_get_by_desc(menu_info_t* mi, const char* desc); void menu_info_item_clicked(GtkWidget* item, GdkEventButton* event, menu_info_item_t* mii); void menu_info_item_scrolled(GtkWidget* item, GdkEventScroll* event, menu_info_item_t* mii); void menu_info_subitem_clicked(GtkWidget* item, GdkEvent* event, menu_info_item_t* mii); void menu_info_item_rename_dialog(GtkWidget* item, GdkEventButton* event, menu_info_item_t* mii); void menu_info_item_remove(menu_info_t* mi, uint32_t index); void menu_info_item_remove_by_name(menu_info_t* mi, const char* name); #endif /* PASYSTRAY_MENU_INFO_H */ pasystray-0.4.0/src/notify.c000066400000000000000000000037341223100446700160230ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #include "config.h" #ifndef HAVE_NOTIFY #include "notify.h" void notify_initialize(){} notify_handle_t notify(const char* msg, const char* body, const char* icon){ return 0; } void notify_update(notify_handle_t h, const char* msg, const char* body, const char* icon){} #else #include typedef struct NotifyNotification* notify_handle_t; void notify_initialize() { notify_init(PACKAGE_NAME); } void notify_show(NotifyNotification* n) { GError* error = NULL; if(!notify_notification_show(n, &error)) g_warning("[notify] unable to show notification: %s: %s (%i)", g_quark_to_string(error->domain), error->message, error->code); } notify_handle_t notify(const char* msg, const char* body, const char* icon) { NotifyNotification* n = notify_notification_new(msg, body, icon); notify_show(n); return (notify_handle_t) n; } void notify_update(notify_handle_t h, const char* msg, const char* body, const char* icon) { NotifyNotification* n = (NotifyNotification*) h; if(!notify_notification_update(n, msg, body, icon)) g_error("[notify] invalid arguments passed to notify_update()"); notify_show(n); } #endif pasystray-0.4.0/src/notify.h000066400000000000000000000021521223100446700160210ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #ifndef PASYSTRAY_NOTIFY_H #define PASYSTRAY_NOTIFY_H #include "config.h" typedef void* notify_handle_t; void notify_initialize(); notify_handle_t notify(const char* msg, const char* body, const char* icon); void notify_update(notify_handle_t h, const char* msg, const char* body, const char* icon); #endif /* PASYSTRAY_NOTIFY_H */ pasystray-0.4.0/src/options.c000066400000000000000000000031021223100446700161730ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #include #include #include #include "config.h" static gboolean version = FALSE; static GOptionEntry entries[] = { { "version", 'V', 0, G_OPTION_ARG_NONE, &version, "print version and exit", NULL }, { .long_name = NULL } }; void parse_options(int argc, char *argv[]) { GError *error = NULL; GOptionContext *context; context = g_option_context_new(NULL); g_option_context_add_main_entries(context, entries, NULL); g_option_context_add_group(context, gtk_get_option_group(TRUE)); if(!g_option_context_parse(context, &argc, &argv, &error)) { g_print("option parsing failed: %s\n", error->message); g_error_free(error); exit(1); } if(version) { g_print("%s\n", VERSION); exit(1); } } pasystray-0.4.0/src/options.h000066400000000000000000000016731223100446700162130ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #ifndef PASYSTRAY_OPTIONS_H #define PASYSTRAY_OPTIONS_H extern gboolean version; void parse_options(int argc, char *argv[]); #endif /* PASYSTRAY_OPTIONS_H */ pasystray-0.4.0/src/pasystray.c000066400000000000000000000031411223100446700165420ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #include #include "pasystray.h" #include "options.h" #include "notify.h" #include "ui.h" #include "menu_info.h" #include "systray.h" #include "pulseaudio.h" #include "avahi.h" #include "x11-property.h" GMainLoop* loop; menu_infos_t* mis; int main(int argc, char *argv[]) { parse_options(argc, argv); gtk_init(&argc, &argv); init(); g_main_loop_run(loop); destroy(); return 0; } void init() { loop = g_main_loop_new(NULL, FALSE); avahi_init(loop); notify_initialize(); x11_property_init(); ui_load(); mis = menu_infos_create(); systray_create(mis); menu_infos_init(mis); pulseaudio_init(mis); avahi_start(mis); } void quit() { g_main_loop_quit(loop); } void destroy() { pulseaudio_destroy(); avahi_destroy(); menu_infos_destroy(mis); } pasystray-0.4.0/src/pasystray.glade000066400000000000000000000122551223100446700174020ustar00rootroot00000000000000 False 5 pasystray dialog pasystray Copyright © 2011, 2012 PulseAudio system tray Christoph Gysin <christoph.gysin@gmail.com> pasystray lgpl-2-1 False vertical 2 True True True end False True end 0 False 5 Rename <device> <name> normal False vertical 2 False Rename <device> <old name> to: False True 0 False end gtk-cancel True False True False True 0 gtk-ok True False True False True 1 False True end 0 True True True True True True False True 4 cancelbutton okbutton pasystray-0.4.0/src/pasystray.h000066400000000000000000000016451223100446700165560ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #ifndef PASYSTRAY_PASYSTRAY_H #define PASYSTRAY_PASYSTRAY_H void init(); void quit(); void destroy(); #endif /* PASYSTRAY_PASYSTRAY_H */ pasystray-0.4.0/src/pulseaudio.c000066400000000000000000000400621223100446700166600ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #include "pulseaudio.h" #include "pulseaudio_info.h" #include "systray.h" #include "systray_impl.h" #include "notify.h" #include pa_context* context = NULL; static pa_glib_mainloop* m = NULL; static pa_proplist* context_proplist = NULL; static char* server = NULL; void pulseaudio_init(menu_infos_t* mis) { if(!(m = pa_glib_mainloop_new(g_main_context_default()))) pulseaudio_quit("pa_glib_mainloop_new() failed."); pulseaudio_prepare_context(); pa_context_set_state_callback(context, pulseaudio_context_state_cb, mis); pulseaudio_connect(); } void pulseaudio_destroy() { pulseaudio_quit(NULL); } void pulseaudio_prepare_context() { pa_mainloop_api* mainloop_api = pa_glib_mainloop_get_api(m); context_proplist = pa_proplist_new(); pa_proplist_sets(context_proplist, PA_PROP_APPLICATION_NAME, "PulseAudio systray"); context = pa_context_new_with_proplist(mainloop_api, NULL, context_proplist); if(!context) pulseaudio_quit("pa_context_new() failed."); } void pulseaudio_connect() { if(pa_context_connect(context, server, 0, NULL) < 0) { g_message("pa_context_connect() failed: "); pulseaudio_quit(pa_strerror(pa_context_errno(context))); } } void pulseaudio_context_state_cb(pa_context* c, void* userdata) { menu_infos_t* mis = userdata; switch(pa_context_get_state(c)) { case PA_CONTEXT_UNCONNECTED: g_message("PulseAudio context unconnected!"); break; case PA_CONTEXT_READY: { char* tooltip = context_info_str(context); char* escaped = g_markup_escape_text(tooltip, -1); char* markup = g_strdup_printf( "%s", escaped); systray_impl_set_tooltip(mis->systray, markup); g_free(escaped); g_free(tooltip); g_free(markup); pa_context_set_subscribe_callback(context, pulseaudio_event_cb, mis); pa_operation_unref(pa_context_subscribe(context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE | PA_SUBSCRIPTION_MASK_SINK_INPUT | PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT | PA_SUBSCRIPTION_MASK_SERVER, pulseaudio_subscribed_cb, mis)); break; } case PA_CONTEXT_FAILED: case PA_CONTEXT_TERMINATED: g_message("PulseAudio terminated!"); menu_infos_clear(mis); pa_context_unref(context); pulseaudio_prepare_context(); g_message("reconnecting..."); pulseaudio_connect(); break; case PA_CONTEXT_CONNECTING: case PA_CONTEXT_AUTHORIZING: case PA_CONTEXT_SETTING_NAME: break; } } void pulseaudio_subscribed_cb(pa_context* c, int success, void* userdata) { menu_infos_t* mis = userdata; pa_operation_unref(pa_context_get_server_info(context, pulseaudio_server_init_cb, &mis->menu_info[MENU_SERVER])); pa_operation_unref(pa_context_get_sink_info_list(context, pulseaudio_sink_init_cb, &mis->menu_info[MENU_SINK])); pa_operation_unref(pa_context_get_source_info_list(context, pulseaudio_source_init_cb, &mis->menu_info[MENU_SOURCE])); pa_operation_unref(pa_context_get_sink_input_info_list(context, pulseaudio_sink_input_init_cb, &mis->menu_info[MENU_INPUT])); pa_operation_unref(pa_context_get_source_output_info_list(context, pulseaudio_source_output_init_cb, &mis->menu_info[MENU_OUTPUT])); } void pulseaudio_event_cb(pa_context* c, pa_subscription_event_type_t t, uint32_t index, void* userdata) { #ifdef DEBUG pulseaudio_print_event(t, index); #endif menu_infos_t* mis = userdata; pa_subscription_event_type_t type = t & PA_SUBSCRIPTION_EVENT_TYPE_MASK; pa_subscription_event_type_t facility = t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK; switch(type) { case PA_SUBSCRIPTION_EVENT_NEW: pulseaudio_event_new(facility, index, mis); break; case PA_SUBSCRIPTION_EVENT_CHANGE: pulseaudio_event_change(facility, index, mis); break; case PA_SUBSCRIPTION_EVENT_REMOVE: pulseaudio_event_remove(facility, index, mis); break; default: break; } } void pulseaudio_event_new(pa_subscription_event_type_t facility, uint32_t index, menu_infos_t* mis) { switch(facility) { case PA_SUBSCRIPTION_EVENT_SERVER: pa_operation_unref(pa_context_get_server_info(context, pulseaudio_server_add_cb, &mis->menu_info[MENU_SERVER])); break; case PA_SUBSCRIPTION_EVENT_SINK: pa_operation_unref(pa_context_get_sink_info_by_index(context, index, pulseaudio_sink_add_cb, &mis->menu_info[MENU_SINK])); break; case PA_SUBSCRIPTION_EVENT_SOURCE: pa_operation_unref(pa_context_get_source_info_by_index(context, index, pulseaudio_source_add_cb, &mis->menu_info[MENU_SOURCE])); break; case PA_SUBSCRIPTION_EVENT_SINK_INPUT: pa_operation_unref(pa_context_get_sink_input_info(context, index, pulseaudio_sink_input_add_cb, &mis->menu_info[MENU_INPUT])); break; case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT: pa_operation_unref(pa_context_get_source_output_info(context, index, pulseaudio_source_output_add_cb, &mis->menu_info[MENU_OUTPUT])); break; default: break; } } void pulseaudio_event_change(pa_subscription_event_type_t facility, uint32_t index, menu_infos_t* mis) { switch(facility) { case PA_SUBSCRIPTION_EVENT_SERVER: pa_operation_unref(pa_context_get_server_info(context, pulseaudio_server_change_cb, &mis->menu_info[MENU_SERVER])); break; case PA_SUBSCRIPTION_EVENT_SINK: pa_operation_unref(pa_context_get_sink_info_by_index(context, index, pulseaudio_sink_change_cb, &mis->menu_info[MENU_SINK])); break; case PA_SUBSCRIPTION_EVENT_SOURCE: pa_operation_unref(pa_context_get_source_info_by_index(context, index, pulseaudio_source_change_cb, &mis->menu_info[MENU_SOURCE])); break; case PA_SUBSCRIPTION_EVENT_SINK_INPUT: pa_operation_unref(pa_context_get_sink_input_info(context, index, pulseaudio_sink_input_change_cb, &mis->menu_info[MENU_INPUT])); break; case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT: pa_operation_unref(pa_context_get_source_output_info(context, index, pulseaudio_source_output_change_cb, &mis->menu_info[MENU_OUTPUT])); break; default: break; } } void pulseaudio_event_remove(pa_subscription_event_type_t facility, uint32_t index, menu_infos_t* mis) { switch(facility) { case PA_SUBSCRIPTION_EVENT_SERVER: menu_info_item_remove(&mis->menu_info[MENU_SERVER], index); break; case PA_SUBSCRIPTION_EVENT_SINK: menu_info_item_remove(&mis->menu_info[MENU_SINK], index); break; case PA_SUBSCRIPTION_EVENT_SOURCE: menu_info_item_remove(&mis->menu_info[MENU_SOURCE], index); break; case PA_SUBSCRIPTION_EVENT_SINK_INPUT: menu_info_item_remove(&mis->menu_info[MENU_INPUT], index); break; case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT: menu_info_item_remove(&mis->menu_info[MENU_OUTPUT], index); break; default: break; } } #ifdef DEBUG void pulseaudio_print_event(pa_subscription_event_type_t t, uint32_t index) { pa_subscription_event_type_t type = t & PA_SUBSCRIPTION_EVENT_TYPE_MASK; pa_subscription_event_type_t facility = t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK; g_message("event %s on %s (%u)", (type == PA_SUBSCRIPTION_EVENT_NEW) ? "new" : (type == PA_SUBSCRIPTION_EVENT_CHANGE) ? "change" : (type == PA_SUBSCRIPTION_EVENT_REMOVE) ? "remove" : "unknown", (facility == PA_SUBSCRIPTION_EVENT_SINK) ? "sink" : (facility == PA_SUBSCRIPTION_EVENT_SOURCE) ? "source" : (facility == PA_SUBSCRIPTION_EVENT_SINK_INPUT) ? "sink-input" : (facility == PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT) ? "source-output" : (facility == PA_SUBSCRIPTION_EVENT_SERVER) ? "server" : "unknown", index); } #endif void pulseaudio_server_init_cb(pa_context* c, const pa_server_info* i, void* userdata) { pulseaudio_server_add(i, userdata, FALSE); } void pulseaudio_server_add_cb(pa_context* c, const pa_server_info* i, void* userdata) { pulseaudio_server_add(i, userdata, TRUE); } void pulseaudio_server_change_cb(pa_context* c, const pa_server_info* i, void* userdata) { pulseaudio_server_add(i, userdata, FALSE); } void pulseaudio_server_add(const pa_server_info* i, void* userdata, gboolean is_new) { menu_info_t* mi = userdata; char* tooltip = server_info_str(i); menu_info_item_update(mi, 0, "localhost", i->host_name, NULL, 0, tooltip, NULL, NULL, -1); g_free(tooltip); /* set default sink/source */ pulseaudio_change_default_item(&mi->menu_infos->menu_info[MENU_SINK], i->default_sink_name); pulseaudio_change_default_item(&mi->menu_infos->menu_info[MENU_SOURCE], i->default_source_name); } void pulseaudio_change_default_item(menu_info_t* mi, const char* new_default) { g_free(mi->default_name); mi->default_name = g_strdup(new_default); menu_info_item_t* item = menu_info_item_get_by_name(mi, new_default); if(item) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item->widget), TRUE); } void pulseaudio_sink_init_cb(pa_context* c, const pa_sink_info* i, int is_last, void* userdata) { pulseaudio_sink_add(i, is_last, userdata, FALSE); } void pulseaudio_sink_add_cb(pa_context* c, const pa_sink_info* i, int is_last, void* userdata) { pulseaudio_sink_add(i, is_last, userdata, TRUE); } void pulseaudio_sink_change_cb(pa_context* c, const pa_sink_info* i, int is_last, void* userdata) { pulseaudio_sink_add(i, is_last, userdata, FALSE); } void pulseaudio_sink_add(const pa_sink_info* i, int is_last, void* userdata, gboolean is_new) { if(is_last < 0) { g_message("Failed to get sink information: %s", pa_strerror(pa_context_errno(context))); return; } if(is_last) return; if(is_new) { gchar* msg = g_strdup_printf("new sink \"%s\"", i->description); notify(msg, i->name, NULL); g_free(msg); } menu_info_t* mi = userdata; char* tooltip = sink_info_str(i); menu_info_item_update(mi, i->index, i->name, i->description, &i->volume, i->mute, tooltip, NULL, NULL, -1); g_free(tooltip); } void pulseaudio_source_init_cb(pa_context* c, const pa_source_info* i, int is_last, void* userdata) { pulseaudio_source_add(i, is_last, userdata, FALSE); } void pulseaudio_source_add_cb(pa_context* c, const pa_source_info* i, int is_last, void* userdata) { pulseaudio_source_add(i, is_last, userdata, TRUE); } void pulseaudio_source_change_cb(pa_context* c, const pa_source_info* i, int is_last, void* userdata) { pulseaudio_source_add(i, is_last, userdata, FALSE); } void pulseaudio_source_add(const pa_source_info* i, int is_last, void* userdata, gboolean is_new) { if(is_last < 0) { g_message("Failed to get source information: %s", pa_strerror(pa_context_errno(context))); return; } if(is_last) return; const char* class = pa_proplist_gets(i->proplist, PA_PROP_DEVICE_CLASS); // ignore monitors if(class && g_str_equal(class, "monitor")) return; if(is_new) { gchar* msg = g_strdup_printf("new source \"%s\"", i->description); notify(msg, i->name, NULL); g_free(msg); } menu_info_t* mi = userdata; char* tooltip = source_info_str(i); menu_info_item_update(mi, i->index, i->name, i->description, &i->volume, i->mute, tooltip, NULL, NULL, -1); g_free(tooltip); } void pulseaudio_sink_input_init_cb(pa_context* c, const pa_sink_input_info* i, int is_last, void* userdata) { pulseaudio_sink_input_add(i, is_last, userdata, FALSE); } void pulseaudio_sink_input_add_cb(pa_context* c, const pa_sink_input_info* i, int is_last, void* userdata) { pulseaudio_sink_input_add(i, is_last, userdata, TRUE); } void pulseaudio_sink_input_change_cb(pa_context* c, const pa_sink_input_info* i, int is_last, void* userdata) { pulseaudio_sink_input_add(i, is_last, userdata, FALSE); } void pulseaudio_sink_input_add(const pa_sink_input_info* i, int is_last, void* userdata, gboolean is_new) { if(is_last < 0) { g_message("Failed to get sink information: %s", pa_strerror(pa_context_errno(context))); return; } if(is_last) return; // ignore filters const char* media_role = pa_proplist_gets(i->proplist, PA_PROP_MEDIA_ROLE); if(media_role && g_str_equal(media_role, "filter")) return; const char* app_name = pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME); const char* app_icon = pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_ICON_NAME); menu_info_t* mi = userdata; char* tooltip = input_info_str(i); menu_info_item_update(mi, i->index, NULL, app_name ? app_name : i->name, &i->volume, i->mute, tooltip, app_icon, NULL, i->sink); g_free(tooltip); } void pulseaudio_source_output_init_cb(pa_context* c, const pa_source_output_info* i, int is_last, void* userdata) { pulseaudio_source_output_add(i, is_last, userdata, FALSE); } void pulseaudio_source_output_add_cb(pa_context* c, const pa_source_output_info* i, int is_last, void* userdata) { pulseaudio_source_output_add(i, is_last, userdata, TRUE); } void pulseaudio_source_output_change_cb(pa_context* c, const pa_source_output_info* i, int is_last, void* userdata) { pulseaudio_source_output_add(i, is_last, userdata, FALSE); } void pulseaudio_source_output_add(const pa_source_output_info* i, int is_last, void* userdata, gboolean is_new) { if(is_last < 0) { g_message("Failed to get source information: %s", pa_strerror(pa_context_errno(context))); return; } if(is_last) return; // ignore peak detects const char* media_name = pa_proplist_gets(i->proplist, PA_PROP_MEDIA_NAME); if(media_name && g_str_equal(media_name, "Peak detect")) return; const char* app_name = pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME); const char* app_icon = pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_ICON_NAME); menu_info_t* mi = userdata; char* tooltip = output_info_str(i); menu_info_item_update(mi, i->index, NULL, app_name ? app_name : i->name, &i->volume, i->mute, tooltip, app_icon, NULL, i->source); g_free(tooltip); } void pulseaudio_quit(const char* msg) { if(msg) g_message("%s", msg); if(context) pa_context_unref(context); if(m) { pa_signal_done(); pa_glib_mainloop_free(m); } } pasystray-0.4.0/src/pulseaudio.h000066400000000000000000000075151223100446700166730ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #ifndef PASYSTRAY_PULSEAUDIO_H #define PASYSTRAY_PULSEAUDIO_H #include #include "menu_info.h" void pulseaudio_init(menu_infos_t* mis); void pulseaudio_destroy(); void pulseaudio_prepare_context(); void pulseaudio_connect(); void pulseaudio_start(); void pulseaudio_context_state_cb(pa_context* c, void* userdata); void pulseaudio_subscribed_cb(pa_context* c, int success, void* userdata); void pulseaudio_event_cb(pa_context* c, pa_subscription_event_type_t t, uint32_t idx, void* userdata); void pulseaudio_event_new(pa_subscription_event_type_t facility, uint32_t index, menu_infos_t* mis); void pulseaudio_event_change(pa_subscription_event_type_t facility, uint32_t index, menu_infos_t* mis); void pulseaudio_event_remove(pa_subscription_event_type_t facility, uint32_t index, menu_infos_t* mis); void pulseaudio_change_default_item(menu_info_t* mi, const char* new_default); void pulseaudio_server_init_cb(pa_context* c, const pa_server_info* i, void* userdata); void pulseaudio_server_add_cb(pa_context* c, const pa_server_info* i, void* userdata); void pulseaudio_server_change_cb(pa_context* c, const pa_server_info* i, void* userdata); void pulseaudio_server_add(const pa_server_info* i, void* userdata, gboolean is_new); void pulseaudio_sink_init_cb(pa_context* c, const pa_sink_info* i, int is_last, void* userdata); void pulseaudio_sink_add_cb(pa_context* c, const pa_sink_info* i, int is_last, void* userdata); void pulseaudio_sink_change_cb(pa_context* c, const pa_sink_info* i, int is_last, void* userdata); void pulseaudio_sink_add(const pa_sink_info* i, int is_last, void* userdata, gboolean is_new); void pulseaudio_source_init_cb(pa_context* c, const pa_source_info* i, int is_last, void* userdata); void pulseaudio_source_add_cb(pa_context* c, const pa_source_info* i, int is_last, void* userdata); void pulseaudio_source_change_cb(pa_context* c, const pa_source_info* i, int is_last, void* userdata); void pulseaudio_source_add(const pa_source_info* i, int is_last, void* userdata, gboolean is_new); void pulseaudio_sink_input_init_cb(pa_context* c, const pa_sink_input_info* i, int is_last, void* userdata); void pulseaudio_sink_input_add_cb(pa_context* c, const pa_sink_input_info* i, int is_last, void* userdata); void pulseaudio_sink_input_change_cb(pa_context* c, const pa_sink_input_info* i, int is_last, void* userdata); void pulseaudio_sink_input_add(const pa_sink_input_info* i, int is_last, void* userdata, gboolean is_new); void pulseaudio_source_output_init_cb(pa_context* c, const pa_source_output_info* i, int is_last, void* userdata); void pulseaudio_source_output_add_cb(pa_context* c, const pa_source_output_info* i, int is_last, void* userdata); void pulseaudio_source_output_change_cb(pa_context* c, const pa_source_output_info* i, int is_last, void* userdata); void pulseaudio_source_output_add(const pa_source_output_info* i, int is_last, void* userdata, gboolean is_new); void pulseaudio_quit(const char* msg); #ifdef DEBUG void pulseaudio_print_event(pa_subscription_event_type_t t, uint32_t index); #endif #endif /* PASYSTRAY_PULSEAUDIO_H */ pasystray-0.4.0/src/pulseaudio_action.c000066400000000000000000000164201223100446700202160ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #include "pulseaudio_action.h" #include #include #include "notify.h" #include "x11-property.h" extern pa_context* context; void pulseaudio_set_default(menu_info_item_t* mii) { pa_operation* o = NULL; switch(mii->menu_info->type) { case MENU_SERVER: if(mii->index == 0) x11_property_del("PULSE_SERVER"); else x11_property_set("PULSE_SERVER", mii->address); break; case MENU_SINK: o = pa_context_set_default_sink(context, mii->name, pulseaudio_set_default_success_cb, mii); break; case MENU_SOURCE: o = pa_context_set_default_source(context, mii->name, pulseaudio_set_default_success_cb, mii); break; case MENU_INPUT: case MENU_OUTPUT: /* nothing to do here */ break; } if(o) pa_operation_unref(o); } void pulseaudio_set_default_success_cb(pa_context *c, int success, void *userdata) { menu_info_item_t* mii = userdata; if(!success) g_error("failed to set default to %s \"%s\"!\n", menu_info_type_name(mii->menu_info->type), mii->name); } void pulseaudio_move_input_to_sink(menu_info_item_t* input, menu_info_item_t* sink) { pa_operation_unref(pa_context_move_sink_input_by_index(context, input->index, sink->index, pulseaudio_move_success_cb, input)); } void pulseaudio_move_output_to_source(menu_info_item_t* output, menu_info_item_t* source) { pa_operation_unref(pa_context_move_source_output_by_index(context, output->index, source->index, pulseaudio_move_success_cb, output)); } void pulseaudio_move_success_cb(pa_context *c, int success, void *userdata) { menu_info_item_t* to = userdata; menu_info_item_t* from = to->menu_info->parent; if(!success) g_error("failed to move %s '%s' to %s '%s'!\n", menu_info_type_name(from->menu_info->type), from->name, menu_info_type_name(to->menu_info->type), to->name); } void pulseaudio_rename(menu_info_item_t* mii, const char* name) { #ifdef DEBUG g_message("rename %s '%s' to '%s'", menu_info_type_name(mii->menu_info->type), mii->desc, name); #endif char *key = g_markup_printf_escaped("%s:%s", menu_info_type_name(mii->menu_info->type), mii->name); pa_operation* o; if(!(o = pa_ext_device_manager_set_device_description(context, key, name, pulseaudio_rename_success_cb, mii))) { g_error("pa_ext_device_manager_set_device_description(context, %s, %s) failed", key, name); return; } pa_operation_unref(o); } void pulseaudio_rename_success_cb(pa_context *c, int success, void *userdata) { menu_info_item_t* mii = userdata; // TODO: try to autoload module-device-manager? if(!success) g_warning("failed to rename %s '%s'! module-device-manager loaded?\n", menu_info_type_name(mii->menu_info->type), mii->name); } void pulseaudio_volume(menu_info_item_t* mii, int inc) { #ifdef DEBUG g_message("pulseaudio_volume(%s, %i)", mii->name, inc); #endif /* increment/decrement in 2% steps */ pa_cvolume* volume; if(inc < 0) volume = pa_cvolume_dec(mii->volume, -inc * PA_VOLUME_NORM / 50); else if(inc > 0) volume = pa_cvolume_inc(mii->volume, inc * PA_VOLUME_NORM / 50); else return; pa_operation* o = NULL; switch(mii->menu_info->type) { case MENU_SERVER: /* nothing to do here */ break; case MENU_SINK: o = pa_context_set_sink_volume_by_index(context, mii->index, volume, pulseaudio_set_volume_success_cb, mii); break; case MENU_SOURCE: o = pa_context_set_source_volume_by_index(context, mii->index, volume, pulseaudio_set_volume_success_cb, mii); break; case MENU_INPUT: o = pa_context_set_sink_input_volume(context, mii->index, volume, pulseaudio_set_volume_success_cb, mii); break; case MENU_OUTPUT: o = pa_context_set_source_output_volume(context, mii->index, volume, pulseaudio_set_volume_success_cb, mii); break; } if(o) pa_operation_unref(o); } void pulseaudio_set_volume_success_cb(pa_context *c, int success, void *userdata) { menu_info_item_t* mii = userdata; if(!success) { g_error("failed to set volume for %s \"%s\"!\n", menu_info_type_name(mii->menu_info->type), mii->name); return; } pulseaudio_update_volume_notification(mii); } void pulseaudio_update_volume_notification(menu_info_item_t* mii) { char vol[PA_CVOLUME_SNPRINT_MAX]; gchar* msg = g_strdup_printf("%s %s: %s%s", menu_info_type_name(mii->menu_info->type), mii->desc, pa_cvolume_snprint(vol, sizeof(vol), mii->volume), mii->mute ? " [muted]" : ""); if(!mii->notify) mii->notify = notify(msg, NULL, mii->icon); else notify_update(mii->notify, msg, NULL, mii->icon); g_free(msg); } void pulseaudio_toggle_mute(menu_info_item_t* mii) { #ifdef DEBUG g_message("pulseaudio_toggle_mute(%s)", mii->name); #endif pa_operation* o = NULL; int mute = (mii->mute) ? 0 : 1; switch(mii->menu_info->type) { case MENU_SERVER: /* nothing to do here */ break; case MENU_SINK: o = pa_context_set_sink_mute_by_index(context, mii->index, mute, pulseaudio_toggle_mute_success_cb, mii); break; case MENU_SOURCE: o = pa_context_set_source_mute_by_index(context, mii->index, mute, pulseaudio_toggle_mute_success_cb, mii); break; case MENU_INPUT: o = pa_context_set_sink_input_mute(context, mii->index, mute, pulseaudio_toggle_mute_success_cb, mii); break; case MENU_OUTPUT: o = pa_context_set_source_output_mute(context, mii->index, mute, pulseaudio_toggle_mute_success_cb, mii); break; } if(o) pa_operation_unref(o); } void pulseaudio_toggle_mute_success_cb(pa_context *c, int success, void *userdata) { menu_info_item_t* mii = userdata; if(!success) g_error("failed to toogle mute for %s \"%s\"!\n", menu_info_type_name(mii->menu_info->type), mii->name); } pasystray-0.4.0/src/pulseaudio_action.h000066400000000000000000000034701223100446700202240ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #ifndef PASYSTRAY_PULSEAUDIO_ACTION_H #define PASYSTRAY_PULSEAUDIO_ACTION_H #include #include "menu_info.h" void pulseaudio_set_default(menu_info_item_t* mii); void pulseaudio_set_default_success_cb(pa_context *c, int success, void *userdata); void pulseaudio_move_input_to_sink(menu_info_item_t* input, menu_info_item_t* sink); void pulseaudio_move_output_to_source(menu_info_item_t* output, menu_info_item_t* source); void pulseaudio_move_success_cb(pa_context *c, int success, void *userdata); void pulseaudio_rename(menu_info_item_t* mii, const char* name); void pulseaudio_rename_success_cb(pa_context *c, int success, void *userdata); void pulseaudio_volume(menu_info_item_t* mii, int inc); void pulseaudio_set_volume_success_cb(pa_context *c, int success, void *userdata); void pulseaudio_update_volume_notification(menu_info_item_t* mii); void pulseaudio_toggle_mute(menu_info_item_t* mii); void pulseaudio_toggle_mute_success_cb(pa_context *c, int success, void *userdata); #endif /* PASYSTRAY_PULSEAUDIO_ACTION_H */ pasystray-0.4.0/src/pulseaudio_info.c000066400000000000000000000257251223100446700177040ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #include #include "pulseaudio_info.h" char* context_info_str(pa_context* c) { return g_strdup_printf( "Server String: %s\n" "Library Protocol Version: %u\n" "Server Protocol Version: %u\n" "Is Local: %s\n" "Client Index: %u\n" "Tile Size: %zu", pa_context_get_server(c), pa_context_get_protocol_version(c), pa_context_get_server_protocol_version(c), pa_context_is_local(c) ? "yes" : "no", pa_context_get_index(c), pa_context_get_tile_size(c, NULL)); } char* server_info_str(const pa_server_info* i) { char ss[PA_SAMPLE_SPEC_SNPRINT_MAX]; char cm[PA_CHANNEL_MAP_SNPRINT_MAX]; pa_sample_spec_snprint(ss, sizeof(ss), &i->sample_spec); pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map); return g_strdup_printf( "User Name: %s\n" "Host Name: %s\n" "Server Name: %s\n" "Server Version: %s\n" "Default Sample Specification: %s\n" "Default Channel Map: %s\n" "Default Sink: %s\n" "Default Source: %s\n" "Cookie: %04x:%04x", i->user_name, i->host_name, i->server_name, i->server_version, ss, cm, i->default_sink_name, i->default_source_name, i->cookie >> 16, i->cookie & 0xFFFFU); } char* sink_info_str(const pa_sink_info* i) { static const char *state_table[] = { [1+PA_SINK_INVALID_STATE] = "n/a", [1+PA_SINK_RUNNING] = "RUNNING", [1+PA_SINK_IDLE] = "IDLE", [1+PA_SINK_SUSPENDED] = "SUSPENDED" }; char s[PA_SAMPLE_SPEC_SNPRINT_MAX]; char cv[PA_CVOLUME_SNPRINT_MAX]; char cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX]; char v[PA_VOLUME_SNPRINT_MAX]; char vdb[PA_SW_VOLUME_SNPRINT_DB_MAX]; char cm[PA_CHANNEL_MAP_SNPRINT_MAX]; char* pl; char* str = g_strdup_printf( "Sink #%u\n" "State: %s\n" "Name: %s\n" "Description: %s\n" "Driver: %s\n" "Sample Specification: %s\n" "Channel Map: %s\n" "Owner Module: %u\n" "Mute: %s\n" "Volume: %s%s%s\n" "Balance: %0.2f\n" "Base Volume: %s%s%s%s\n" "Monitor Source: %s\n" "Latency: %0.0f usec, configured %0.0f usec\n" "Flags: %s%s%s%s%s%s%s\n" "Properties:\n\t\t%s", i->index, state_table[1+i->state], i->name, i->description, i->driver, pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec), pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), i->owner_module, i->mute ? "yes" : "no", pa_cvolume_snprint(cv, sizeof(cv), &i->volume), i->flags & PA_SINK_DECIBEL_VOLUME ? "\n " : "", i->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume) : "", pa_cvolume_get_balance(&i->volume, &i->channel_map), pa_volume_snprint(v, sizeof(v), i->base_volume), i->flags & PA_SINK_DECIBEL_VOLUME ? " (" : "", i->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), i->base_volume) : "", i->flags & PA_SINK_DECIBEL_VOLUME ? ")" : "", i->monitor_source_name, (double) i->latency, (double) i->configured_latency, i->flags & PA_SINK_HARDWARE ? "HARDWARE " : "", i->flags & PA_SINK_NETWORK ? "NETWORK " : "", i->flags & PA_SINK_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "", i->flags & PA_SINK_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "", i->flags & PA_SINK_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "", i->flags & PA_SINK_LATENCY ? "LATENCY " : "", i->flags & PA_SINK_SET_FORMATS ? "SET_FORMATS " : "", pl = pa_proplist_to_string_sep(i->proplist, "\n\t\t")); pa_xfree(pl); return str; } char* source_info_str(const pa_source_info* i) { static const char *state_table[] = { [1+PA_SOURCE_INVALID_STATE] = "n/a", [1+PA_SOURCE_RUNNING] = "RUNNING", [1+PA_SOURCE_IDLE] = "IDLE", [1+PA_SOURCE_SUSPENDED] = "SUSPENDED" }; char s[PA_SAMPLE_SPEC_SNPRINT_MAX]; char cv[PA_CVOLUME_SNPRINT_MAX]; char cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX]; char v[PA_VOLUME_SNPRINT_MAX]; char vdb[PA_SW_VOLUME_SNPRINT_DB_MAX]; char cm[PA_CHANNEL_MAP_SNPRINT_MAX]; char *pl; char* str = g_strdup_printf( "Source #%u\n" "State: %s\n" "Name: %s\n" "Description: %s\n" "Driver: %s\n" "Sample Specification: %s\n" "Channel Map: %s\n" "Owner Module: %u\n" "Mute: %s\n" "Volume: %s%s%s\n" "Balance: %0.2f\n" "Base Volume: %s%s%s%s\n" "Monitor of Sink: %s\n" "Latency: %0.0f usec, configured %0.0f usec\n" "Flags: %s%s%s%s%s%s\n" "Properties:\n\t\t%s", i->index, state_table[1+i->state], i->name, i->description, i->driver, pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec), pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), i->owner_module, i->mute ? "yes" : "no", pa_cvolume_snprint(cv, sizeof(cv), &i->volume), i->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n " : "", i->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume) : "", pa_cvolume_get_balance(&i->volume, &i->channel_map), pa_volume_snprint(v, sizeof(v), i->base_volume), i->flags & PA_SOURCE_DECIBEL_VOLUME ? " (" : "", i->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), i->base_volume) : "", i->flags & PA_SOURCE_DECIBEL_VOLUME ? ")" : "", i->monitor_of_sink_name ? i->monitor_of_sink_name : "n/a", (double) i->latency, (double) i->configured_latency, i->flags & PA_SOURCE_HARDWARE ? "HARDWARE " : "", i->flags & PA_SOURCE_NETWORK ? "NETWORK " : "", i->flags & PA_SOURCE_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "", i->flags & PA_SOURCE_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "", i->flags & PA_SOURCE_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "", i->flags & PA_SOURCE_LATENCY ? "LATENCY " : "", pl = pa_proplist_to_string_sep(i->proplist, "\n\t\t")); pa_xfree(pl); return str; } char* input_info_str(const pa_sink_input_info* i) { char t[32]; char k[32]; char s[PA_SAMPLE_SPEC_SNPRINT_MAX]; char cv[PA_CVOLUME_SNPRINT_MAX]; char cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX]; char cm[PA_CHANNEL_MAP_SNPRINT_MAX]; char f[PA_FORMAT_INFO_SNPRINT_MAX]; char *pl; g_snprintf(t, sizeof(t), "%u", i->owner_module); g_snprintf(k, sizeof(k), "%u", i->client); char* str = g_strdup_printf( "Sink Input #%u\n" "Driver: %s\n" "Owner Module: %s\n" "Client: %s\n" "Sink: %u\n" "Sample Specification: %s\n" "Channel Map: %s\n" "Format: %s\n" "Mute: %s\n" "Volume: %s\n" " %s\n" "Balance: %0.2f\n" "Buffer Latency: %0.0f usec\n" "Sink Latency: %0.0f usec\n" "Resample method: %s\n" "Properties:\n\t\t%s", i->index, i->driver, i->owner_module != PA_INVALID_INDEX ? t : "n/a", i->client != PA_INVALID_INDEX ? k : "n/a", i->sink, pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec), pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), pa_format_info_snprint(f, sizeof(f), i->format), i->mute ? "yes" : "no", pa_cvolume_snprint(cv, sizeof(cv), &i->volume), pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume), pa_cvolume_get_balance(&i->volume, &i->channel_map), (double) i->buffer_usec, (double) i->sink_usec, i->resample_method ? i->resample_method : "n/a", pl = pa_proplist_to_string_sep(i->proplist, "\n\t\t")); pa_xfree(pl); return str; } char* output_info_str(const pa_source_output_info* i) { char t[32]; char k[32]; char s[PA_SAMPLE_SPEC_SNPRINT_MAX]; char cv[PA_CVOLUME_SNPRINT_MAX]; char cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX]; char cm[PA_CHANNEL_MAP_SNPRINT_MAX]; char f[PA_FORMAT_INFO_SNPRINT_MAX]; char *pl; g_snprintf(t, sizeof(t), "%u", i->owner_module); g_snprintf(k, sizeof(k), "%u", i->client); char* str = g_strdup_printf( "Source Output #%u\n" "Driver: %s\n" "Owner Module: %s\n" "Client: %s\n" "Source: %u\n" "Sample Specification: %s\n" "Channel Map: %s\n" "Format: %s\n" "Mute: %s\n" "Volume: %s\n" " %s\n" "Balance: %0.2f\n" "Buffer Latency: %0.0f usec\n" "Source Latency: %0.0f usec\n" "Resample method: %s\n" "Properties:\n\t\t%s", i->index, i->driver, i->owner_module != PA_INVALID_INDEX ? t : "n/a", i->client != PA_INVALID_INDEX ? k : "n/a", i->source, pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec), pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), pa_format_info_snprint(f, sizeof(f), i->format), i->mute ? "yes" : "no", pa_cvolume_snprint(cv, sizeof(cv), &i->volume), pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume), pa_cvolume_get_balance(&i->volume, &i->channel_map), (double) i->buffer_usec, (double) i->source_usec, i->resample_method ? i->resample_method : "n/a", pl = pa_proplist_to_string_sep(i->proplist, "\n\t\t")); pa_xfree(pl); return str; } pasystray-0.4.0/src/pulseaudio_info.h000066400000000000000000000023111223100446700176730ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #ifndef PASYSTRAY_PULSEAUDIO_INFO_H #define PASYSTRAY_PULSEAUDIO_INFO_H #include char* context_info_str(pa_context* c); char* server_info_str(const pa_server_info* i); char* sink_info_str(const pa_sink_info* i); char* source_info_str(const pa_source_info* i); char* input_info_str(const pa_sink_input_info* i); char* output_info_str(const pa_source_output_info* i); #endif /* PASYSTRAY_PULSEAUDIO_INFO_H */ pasystray-0.4.0/src/systray.c000066400000000000000000000277231223100446700162350ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #include "systray.h" #include "pasystray.h" #include "config.h" #include "pulseaudio_action.h" #include "ui.h" #include "systray_impl.h" void systray_create(menu_infos_t* mis) { systray_menu_create(mis); mis->systray = systray_impl_create(mis); } void systray_menu_create(menu_infos_t* mis) { mis->menu = GTK_MENU_SHELL(gtk_menu_new()); systray_rootmenu_add_submenu(mis, MENU_SERVER, "Default _Server", "network-wired"); systray_rootmenu_add_submenu(mis, MENU_SINK, "Default S_ink", "audio-card"); systray_rootmenu_add_submenu(mis, MENU_SOURCE, "Default S_ource", "audio-input-microphone"); systray_rootmenu_add_submenu(mis, MENU_INPUT, "Playback S_treams", "player_play"); systray_rootmenu_add_submenu(mis, MENU_OUTPUT, "Recording Stre_ams", "player_record"); systray_menu_add_separator(mis->menu); static const char* COMMAND_PAMAN = "paman"; static const char* COMMAND_PAVUCONTROL = "pavucontrol"; static const char* COMMAND_PAVUMETER = "pavumeter"; static const char* COMMAND_PAVUMETER_REC = "pavumeter --record"; static const char* COMMAND_PAPREFS = "paprefs"; systray_menu_add_application(mis->menu, "_Manager...", NULL, COMMAND_PAMAN); systray_menu_add_application(mis->menu, "Volume _Control...", NULL, COMMAND_PAVUCONTROL); systray_menu_add_application(mis->menu, "Volume Meter (_Playback)...", NULL, COMMAND_PAVUMETER); systray_menu_add_application(mis->menu, "Volume Meter (_Recording)...", NULL, COMMAND_PAVUMETER_REC); systray_menu_add_application(mis->menu, "Con_figure Local Sound Server...", NULL, COMMAND_PAPREFS); /* TODO: settings systray_menu_add_separator(mis->menu); item = append_menuitem(mis->menu, "_Preferences...", "gtk-preferences"); g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(show_preferences), NULL); */ systray_menu_add_separator(mis->menu); gtk_menu_shell_append(GTK_MENU_SHELL(mis->menu), systray_menu_item_about()); gtk_menu_shell_append(GTK_MENU_SHELL(mis->menu), systray_menu_item_quit()); } void systray_menu_add_separator(GtkMenuShell* menu) { GtkWidget* item = gtk_separator_menu_item_new(); gtk_menu_shell_append(menu, item); gtk_widget_show(item); } void systray_rootmenu_add_submenu(menu_infos_t* mis, menu_type_t type, const char* name, const char* icon) { GtkMenuShell* menu = mis->menu; menu_info_t* mi = &mis->menu_info[type]; systray_menu_add_submenu(menu, mi, name, NULL, icon); systray_menu_add_item(mi->menu, "none", NULL, FALSE); } GtkWidget* systray_menu_add_submenu(GtkMenuShell* menu, menu_info_t* mi, const char* name, const char* tooltip, const char* icon) { GtkWidget* submenu = gtk_menu_new(); mi->menu = GTK_MENU_SHELL(submenu); mi->group = NULL; /* if this is the first item, remove the "none" placeholder label */ if(mi->parent) { menu_info_t* parent_mi = mi->parent->menu_info; if(g_hash_table_size(parent_mi->items) == 0) { GList* children = gtk_container_get_children(GTK_CONTAINER(parent_mi->menu)); if(children) gtk_container_remove(GTK_CONTAINER(parent_mi->menu), GTK_WIDGET(children->data)); } } GtkWidget* item = systray_add_menu_item(menu, name, tooltip, icon); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); return item; } GtkWidget* systray_add_menu_item(GtkMenuShell* menu, const char* desc, const char* tooltip, const char* icon) { GtkWidget* item = gtk_image_menu_item_new_with_mnemonic(desc); gtk_menu_shell_append(menu, item); if(tooltip) systray_set_tooltip(item, tooltip); if(icon) gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), gtk_image_new_from_icon_name(icon, GTK_ICON_SIZE_MENU)); gtk_widget_show(item); return item; } void systray_remove_menu_item(menu_info_t* mi, GtkWidget* item) { gtk_container_remove(GTK_CONTAINER(mi->menu), item); /* insert "none" placeholder label for empty menus */ if(!mi->parent) if(g_hash_table_size(mi->items) <= 1) systray_menu_add_item(mi->menu, "none", NULL, FALSE); } GtkWidget* systray_add_radio_item(menu_info_t* mi, const char* desc, const char* tooltip) { GtkWidget* item = gtk_radio_menu_item_new_with_label(mi->group, desc); if(tooltip) systray_set_tooltip(item, tooltip); mi->group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item)); /* if this is the first item, remove the "none" placeholder label */ if(g_hash_table_size(mi->items) == 0) { GList* children = gtk_container_get_children(GTK_CONTAINER(mi->menu)); if(children) gtk_container_remove(GTK_CONTAINER(mi->menu), GTK_WIDGET(children->data)); } gtk_menu_shell_append(mi->menu, item); gtk_widget_show(item); return item; } void systray_remove_radio_item(menu_info_t* mi, GtkWidget* item) { gtk_radio_menu_item_set_group(GTK_RADIO_MENU_ITEM(item), NULL); gtk_container_remove(GTK_CONTAINER(mi->menu), item); /* update group */ GList* children = gtk_container_get_children(GTK_CONTAINER(mi->menu)); if(children) mi->group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(children->data)); else mi->group = NULL; } GtkWidget* systray_menu_add_item(GtkMenuShell* menu, const char* name, const char* icon, gboolean sensitive) { GtkWidget* item = systray_add_menu_item(menu, name, NULL, icon); gtk_widget_set_sensitive(item, sensitive); return item; } void systray_menu_add_application(GtkMenuShell* menu, const char* name, const char* icon, const char* command) { gchar** exe = g_strsplit_set(command, " ", 2); gchar* c = g_find_program_in_path(exe[0]); g_strfreev(exe); GtkWidget* item = systray_menu_add_item(menu, name, icon, (c != NULL)); g_free(c); g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(start_application_cb), (gpointer)command); } void systray_remove_item(menu_info_item_t* mii) { menu_info_t* mi = mii->menu_info; menu_infos_t* mis = mi->menu_infos; switch(mi->type) { case MENU_SERVER: systray_remove_radio_item(mi, mii->widget); break; case MENU_SINK: if(!mii->menu_info->parent) systray_remove_item_from_all_submenus(mii, &mis->menu_info[MENU_INPUT]); systray_remove_radio_item(mi, mii->widget); break; case MENU_SOURCE: if(!mii->menu_info->parent) systray_remove_item_from_all_submenus(mii, &mis->menu_info[MENU_OUTPUT]); systray_remove_radio_item(mi, mii->widget); break; case MENU_INPUT: case MENU_OUTPUT: systray_remove_all_items_from_submenu(mii->submenu); systray_remove_menu_item(mi, mii->widget); break; } } void systray_add_all_items_to_submenu(menu_info_t* submenu, menu_info_item_t* item) { GHashTableIter iter; gpointer key; menu_info_item_t* mii; g_hash_table_iter_init(&iter, submenu->items); while(g_hash_table_iter_next(&iter, &key, (gpointer*)&mii)) menu_info_subitem_add(item->submenu, mii->index, mii->name, mii->desc, NULL, NULL); } void systray_update_all_items_in_submenu(menu_info_t* submenu, menu_info_item_t* item) { GHashTableIter iter; gpointer key; menu_info_item_t* mii; g_hash_table_iter_init(&iter, submenu->items); while(g_hash_table_iter_next(&iter, &key, (gpointer*)&mii)) menu_info_subitem_update(item->submenu, mii->index, mii->name, mii->desc, NULL, NULL); } void systray_remove_all_items_from_submenu(menu_info_t* submenu) { GHashTableIter iter; gpointer key; menu_info_item_t* mii; g_hash_table_iter_init(&iter, submenu->items); while(g_hash_table_iter_next(&iter, &key, (gpointer*)&mii)) systray_remove_menu_item(submenu, mii->widget); } void systray_add_item_to_all_submenus(menu_info_item_t* item, menu_info_t* submenu) { GHashTableIter iter; gpointer key; menu_info_item_t* mii; g_hash_table_iter_init(&iter, submenu->items); while(g_hash_table_iter_next(&iter, &key, (gpointer*)&mii)) menu_info_subitem_add(mii->submenu, item->index, item->name, item->desc, NULL, NULL); } void systray_update_item_in_all_submenus(menu_info_item_t* item, menu_info_t* submenu) { GHashTableIter iter; gpointer key; menu_info_item_t* mii; g_hash_table_iter_init(&iter, submenu->items); while(g_hash_table_iter_next(&iter, &key, (gpointer*)&mii)) menu_info_subitem_update(mii->submenu, item->index, item->name, item->desc, NULL, NULL); } void systray_remove_item_from_all_submenus(menu_info_item_t* item, menu_info_t* submenu) { GHashTableIter iter; gpointer key; menu_info_item_t* mii; g_hash_table_iter_init(&iter, submenu->items); while(g_hash_table_iter_next(&iter, &key, (gpointer*)&mii)) menu_info_item_remove(mii->submenu, item->index); } GtkWidget* systray_menu_item_about() { GtkWidget* item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL); g_signal_connect(item, "activate", G_CALLBACK(systray_about_dialog), NULL); gtk_widget_show(item); return item; } void systray_about_dialog() { GtkAboutDialog* dialog = ui_aboutdialog(); g_signal_connect_swapped(dialog, "response", G_CALLBACK(gtk_widget_hide), dialog); gtk_widget_show_all(GTK_WIDGET(dialog)); } GtkWidget* systray_menu_item_quit() { GtkWidget* item = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL); g_signal_connect(item, "activate", G_CALLBACK(quit), NULL); gtk_widget_show(item); return item; } void systray_click_cb(GtkStatusIcon* icon, GdkEventButton* ev, gpointer userdata) { menu_infos_t* mis = userdata; switch(ev->button) { case 1: case 3: gtk_menu_popup(GTK_MENU(mis->menu), NULL, NULL, gtk_status_icon_position_menu, icon, ev->button, ev->time); break; case 2: { menu_info_t* mi = &mis->menu_info[(ev->state & GDK_CONTROL_MASK) ? MENU_SOURCE : MENU_SINK]; menu_info_item_t* mii = menu_info_item_get_by_name(mi, mi->default_name); if(mii) pulseaudio_toggle_mute(mii); } break; } } void systray_scroll_cb(systray_t* systray, guint state, GdkScrollDirection direction, menu_infos_t* mis) { int inc = 0; switch(direction) { case GDK_SCROLL_UP: inc = 1; break; case GDK_SCROLL_DOWN: inc = -1; break; default: return; } menu_info_t* mi = &mis->menu_info[(state & GDK_CONTROL_MASK) ? MENU_SOURCE : MENU_SINK]; menu_info_item_t* mii = menu_info_item_get_by_name(mi, mi->default_name); if(mii) pulseaudio_volume(mii, inc); } void start_application_cb(GtkMenuItem* item, const char* command) { g_spawn_command_line_async(command, NULL); } void systray_set_tooltip(GtkWidget* item, const char* tooltip) { char* escaped = g_markup_escape_text(tooltip, -1); char* markup = g_strdup_printf("%s", escaped); gtk_widget_set_tooltip_markup(item, markup); g_free(escaped); g_free(markup); } pasystray-0.4.0/src/systray.h000066400000000000000000000054741223100446700162410ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #ifndef PASYSTRAY_SYSTRAY_H #define PASYSTRAY_SYSTRAY_H #include #include "menu_info.h" #include "systray_impl.h" void systray_create(menu_infos_t* mis); void systray_menu_create(menu_infos_t* mis); void systray_rootmenu_add_submenu(menu_infos_t* mis, menu_type_t type, const char* name, const char* icon); GtkWidget* systray_menu_add_submenu(GtkMenuShell* menu, menu_info_t* mis, const char* name, const char* tooltip, const char* icon); void systray_menu_add_separator(GtkMenuShell* menu); GtkWidget* systray_menu_add_item(GtkMenuShell* menu, const char* name, const char* icon, gboolean sensitive); void systray_menu_add_application(GtkMenuShell* menu, const char* text, const char* icon, const char* command); void systray_remove_item(menu_info_item_t* mii); GtkWidget* systray_add_menu_item(GtkMenuShell* menu, const char* desc, const char* tooltip, const char* icon); void systray_remove_menu_item(menu_info_t* mi, GtkWidget* item); GtkWidget* systray_add_radio_item(menu_info_t* m, const char* desc, const char* tooltip); void systray_remove_radio_item(menu_info_t* mi, GtkWidget* item); void systray_add_all_items_to_submenu(menu_info_t* submenu, menu_info_item_t* item); void systray_update_all_items_in_submenu(menu_info_t* submenu, menu_info_item_t* item); void systray_remove_all_items_from_submenu(menu_info_t* submenu); void systray_add_item_to_all_submenus(menu_info_item_t* item, menu_info_t* submenu); void systray_update_item_in_all_submenus(menu_info_item_t* item, menu_info_t* submenu); void systray_remove_item_from_all_submenus(menu_info_item_t* item, menu_info_t* submenu); GtkWidget* systray_menu_item_about(); void systray_about_dialog(); GtkWidget* systray_menu_item_quit(); void systray_click_cb(GtkStatusIcon* icon, GdkEventButton* ev, gpointer userdata); void systray_scroll_cb(systray_t* systray, guint state, GdkScrollDirection direction, menu_infos_t* mis); void start_application_cb(GtkMenuItem* menuitem, const char* command); void systray_set_tooltip(GtkWidget* item, const char* tooltip); #endif /* PASYSTRAY_SYSTRAY_H */ pasystray-0.4.0/src/systray_impl.c000066400000000000000000000077561223100446700172620ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #include "systray_impl.h" #include "config.h" #include "systray.h" #ifdef HAVE_APPINDICATOR #include static void systray_impl_scroll_cb(AppIndicator* appind, gint delta, GdkScrollDirection direction, gpointer userdata) { systray_t systray = appind; guint state = 0; // TODO: get modifiers? menu_infos_t* mis = userdata; systray_scroll_cb(systray, state, direction, mis); } systray_t systray_impl_create(menu_infos_t* mis) { #ifdef DEBUG g_message("creating systray implementation using AppIndicator"); #endif AppIndicator* appind = app_indicator_new("pasystray", "pasystray", APP_INDICATOR_CATEGORY_HARDWARE); app_indicator_set_status(appind, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_icon_full(appind, "pasystray", "pasystray"); app_indicator_set_menu(appind, GTK_MENU(mis->menu)); g_signal_connect(appind, "scroll-event", G_CALLBACK(systray_impl_scroll_cb), mis); return appind; } void systray_impl_set_icon(systray_t systray, const char* icon_name) { AppIndicator* appind = systray; app_indicator_set_icon_full(appind, icon_name, icon_name); } void systray_impl_set_tooltip(systray_t systray, const char* markup) { // TODO: set tooltip? } #else #include "ui.h" static void systray_impl_scroll_cb(GtkStatusIcon* icon, GdkEventScroll* ev, gpointer userdata) { systray_t systray = icon; menu_infos_t* mis = userdata; systray_scroll_cb(systray, ev->state, ev->direction, mis); } static GtkStatusIcon* systray_impl_create_statusicon() { GtkStatusIcon* status_icon = gtk_status_icon_new(); gtk_status_icon_set_from_icon_name(status_icon, "pasystray"); gtk_status_icon_set_title(status_icon, "PulseAudio system tray"); #ifdef DEBUG GError* error = NULL; gchar* exe_path = g_file_read_link("/proc/self/exe", &error); if(error) { g_message("g_file_read_link() failed (%s)", error->message); g_error_free(error); g_free(exe_path); return status_icon; } gchar* dirname = g_path_get_dirname(exe_path); g_free(exe_path); gchar* icon_file = g_build_path("/", dirname, "../data/pasystray.svg", NULL); g_free(dirname); if(g_file_test(icon_file, G_FILE_TEST_EXISTS)) { gtk_status_icon_set_from_file(status_icon, icon_file); g_message("using icon: %s", icon_file); } g_free(icon_file); #endif return status_icon; } systray_t systray_impl_create(menu_infos_t* mis) { #ifdef DEBUG g_message("creating systray implementation using GtkStatusIcon"); #endif GtkStatusIcon* icon = systray_impl_create_statusicon(); g_signal_connect(icon, "button-press-event", G_CALLBACK(systray_click_cb), mis); g_signal_connect(icon, "scroll-event", G_CALLBACK(systray_impl_scroll_cb), mis); gtk_status_icon_set_tooltip_text(icon, "connecting to server..."); gtk_status_icon_set_visible(icon, TRUE); return icon; } void systray_impl_set_icon(systray_t systray, const char* icon_name) { GtkStatusIcon* icon = systray; gtk_status_icon_set_from_icon_name(icon, icon_name); } void systray_impl_set_tooltip(systray_t systray, const char* markup) { GtkStatusIcon* icon = systray; gtk_status_icon_set_tooltip_markup(icon, markup); } #endif pasystray-0.4.0/src/systray_impl.h000066400000000000000000000021321223100446700172460ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #ifndef PASYSTRAY_SYSTRAY_IMPL_H #define PASYSTRAY_SYSTRAY_IMPL_H #include "menu_info.h" systray_t systray_impl_create(menu_infos_t* mis); void systray_impl_set_icon(systray_t systray, const char* icon_name); void systray_impl_set_tooltip(systray_t systray, const char* markup); #endif /* PASYSTRAY_SYSTRAY_IMPL_H */ pasystray-0.4.0/src/ui.c000066400000000000000000000055761223100446700151360ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #include "ui.h" #include "config.h" #include "systray_impl.h" static GtkBuilder* builder; void ui_load() { builder = gtk_builder_new(); GError* error = NULL; // GLADE_FILE is set in src/Makefile.am const char* filename = GLADE_FILE; #ifdef DEBUG /* try to load ui in current dir first */ char* local_file = "pasystray.glade"; if(g_file_test(local_file, G_FILE_TEST_EXISTS)) filename = local_file; local_file = "src/pasystray.glade"; if(g_file_test(local_file, G_FILE_TEST_EXISTS)) filename = local_file; g_message("using UI file: %s", filename); #endif guint ret = gtk_builder_add_from_file(builder, filename, &error); if(!ret) { g_error("[ui] %s", error->message); g_error_free(error); return; } gtk_about_dialog_set_version(ui_aboutdialog(), PACKAGE_VERSION); gtk_about_dialog_set_website(ui_aboutdialog(), PACKAGE_URL); gtk_about_dialog_set_website_label(ui_aboutdialog(), PACKAGE_URL); } void ui_update_systray_icon(menu_info_item_t* mii) { #ifdef DEBUG g_message("pulseaudio_update_systray_icon(%s)", mii->name); #endif pa_volume_t volume = pa_cvolume_avg(mii->volume); g_message("volume:%u%s", volume, mii->mute ? " muted" : ""); const char* icon_name = NULL; if(volume == PA_VOLUME_MUTED || mii->mute) icon_name = "stock_volume-mute"; else if(volume < (PA_VOLUME_NORM / 3)) icon_name = "stock_volume-min"; else if(volume < (PA_VOLUME_NORM / 3 * 2)) icon_name = "stock_volume-med"; else icon_name = "stock_volume-max"; menu_infos_t* mis = mii->menu_info->menu_infos; systray_impl_set_icon(mis->systray, icon_name); } GtkAboutDialog* ui_aboutdialog() { return (GtkAboutDialog*) gtk_builder_get_object(builder, "aboutdialog"); } GtkDialog* ui_renamedialog() { return (GtkDialog*) gtk_builder_get_object(builder, "renamedialog"); } GtkLabel* ui_renamedialog_label() { return (GtkLabel*) gtk_builder_get_object(builder, "label"); } GtkEntry* ui_renamedialog_entry() { return (GtkEntry*) gtk_builder_get_object(builder, "entry"); } pasystray-0.4.0/src/ui.h000066400000000000000000000021361223100446700151300ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #ifndef PASYSTRAY_UI_H #define PASYSTRAY_UI_H #include "menu_info.h" #include void ui_load(); void ui_update_systray_icon(menu_info_item_t* mii); GtkAboutDialog* ui_aboutdialog(); GtkDialog* ui_renamedialog(); GtkLabel* ui_renamedialog_label(); GtkEntry* ui_renamedialog_entry(); #endif /* PASYSTRAY_UI_H */ pasystray-0.4.0/src/x11-property.c000066400000000000000000000050151223100446700170000ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #include "config.h" #ifndef HAVE_X11 #include void x11_property_init(){} void x11_property_set(const char* key, const char* value){} void x11_property_del(const char* key){} char* x11_property_get(const char* key){ return NULL; } #else #include #include #include #include static Display* display = NULL; static Window window; void x11_property_init() { display = gdk_x11_get_default_xdisplay(); window = RootWindow(display, 0); } void x11_property_set(const char* key, const char* value) { #ifdef DEBUG g_message("[x11-property] setting '%s' to '%s'", key, value); #endif Atom atom = XInternAtom(display, key, False); XChangeProperty(display, window, atom, XA_STRING, 8, PropModeReplace, (const unsigned char*) value, strlen(value)+1); } void x11_property_del(const char* key) { #ifdef DEBUG g_message("[x11-property] deleting '%s'", key); #endif Atom atom = XInternAtom(display, key, False); XDeleteProperty(display, window, atom); } char* x11_property_get(const char* key) { Atom property = XInternAtom(display, key, False); Atom actual_type; int actual_format; unsigned long nitems; unsigned long bytes_after; unsigned char* prop = NULL; char* value = NULL; if(XGetWindowProperty( display, window, property, 0, 64, False, XA_STRING, &actual_type, &actual_format, &nitems, &bytes_after, &prop ) != Success) goto finish; if(actual_type != XA_STRING) goto finish; value = g_memdup(prop, nitems + 1); #ifdef DEBUG g_message("[x11-property] got '%s' = '%s'", key, value); #endif finish: if(prop) XFree(prop); return value; } #endif pasystray-0.4.0/src/x11-property.h000066400000000000000000000020521223100446700170030ustar00rootroot00000000000000/*** This file is part of PaSystray Copyright (C) 2011, 2012 Christoph Gysin PaSystray is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PaSystray is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with PaSystray; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ #ifndef PASYSTRAY_X11_PROPERTY_H #define PASYSTRAY_X11_PROPERTY_H void x11_property_init(); void x11_property_set(const char* key, const char* value); void x11_property_del(const char* key); char* x11_property_get(const char* key); #endif /* PASYSTRAY_X11_PROPERTY_H */