bzr branch lp:indicator-sound
[CCode (cheader_filename="libintl.h", type="char *")] extern unowned string bind_textdomain_codeset (string domainname, string codeset); static int main (string[] args) { bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8"); Intl.setlocale (LocaleCategory.ALL, ""); Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.GNOMELOCALEDIR); Notify.init ("indicator-sound"); var service = new IndicatorSound.Service (); return service.run (); }
var service = new IndicatorSound.Service ();
//... void bus_acquired (DBusConnection connection, string name) {//...} //... void name_lost (DBusConnection connection, string name) {//...} //...
sudo apt-get install qdbus-qt5
public int run () { if (this.loop != null) { warning ("service is already running"); return 1; } Bus.own_name (BusType.SESSION, "com.canonical.indicator.sound", BusNameOwnerFlags.NONE, this.bus_acquired, null, this.name_lost); this.loop = new MainLoop (null, false); this.loop.run (); return 0; }
$ gdbus introspect --session --dest com.canonical.indicator.sound --object-path \ /com/canonical/indicator/sound node /com/canonical/indicator/sound { interface org.freedesktop.DBus.Properties { methods: Get(in s interface_name, in s property_name, out v value); GetAll(in s interface_name, out a{sv} properties); Set(in s interface_name, in s property_name, in v value); signals: PropertiesChanged(s interface_name, a{sv} changed_properties, as invalidated_properties); properties: }; interface org.freedesktop.DBus.Introspectable { methods: Introspect(out s xml_data); signals: properties: }; interface org.freedesktop.DBus.Peer { methods: Ping(); GetMachineId(out s machine_uuid); signals: properties: }; interface org.gtk.Actions { methods: List(out as list); Describe(in s action_name, out (bgav) description); DescribeAll(out a{s(bgav)} descriptions); Activate(in s action_name, in av parameter, in a{sv} platform_data); SetState(in s action_name, in v value, in a{sv} platform_data); signals: Changed(as removals, a{sb} enable_changes, a{sv} state_changes, a{s(bgav)} additions); properties: }; node desktop_greeter { }; node phone { }; node desktop { }; };
dbus-monitor > monitor.log
.... # , , , method call sender=:1.9 -> dest=:1.19 serial=27912 path=/com/canonical/indicator/sound; interface=org.gtk.Actions; member=Activate string "play.vkcomvkcom.desktop" array [ ] array [ ] ... # : ... #Next method call sender=:1.9 -> dest=:1.19 serial=27918 path=/com/canonical/indicator/sound; interface=org.gtk.Actions; member=Activate string "next.vkcomvkcom.desktop" array [ ] array [ ] ... #Previous method call sender=:1.9 -> dest=:1.19 serial=27918 path=/com/canonical/indicator/sound; interface=org.gtk.Actions; member=Activate string "previous.vkcomvkcom.desktop" array [ ] array [ ] ...
#Play/Pause gdbus call --session --dest com.canonical.indicator.sound --object-path /com/canonical/indicator/sound \ --method org.gtk.Actions.Activate 'play.vkcomvkcom.desktop' [] {} #Next gdbus call --session --dest com.canonical.indicator.sound --object-path /com/canonical/indicator/sound \ --method org.gtk.Actions.Activate 'next.vkcomvkcom.desktop' [] {} #Previous . .. ...
gdbus call --session --dest com.canonical.indicator.sound --object-path /com/canonical/indicator/sound --method org.gtk.Actions.List
dconf read /com/canonical/indicator/sound/interested-media-players
dconf read /com/canonical/indicator/sound/interested-media-players | sed -e "s:[],'\[]::g" -e "s:\s:\n:g"
# UCS_CACHE=~/.cache/unity-control-sound UCS_CURRENT_PLAYER_FILE=$UCS_CACHE/current-player # UCS_INTERESTED_PLAYERS=`dconf read \ /com/canonical/indicator/sound/interested-media-players \ | sed -e"s:[],'\[]::g" ` # UCS_PREFFERED_PLAYERS=`dconf read /com/canonical/indicator/sound/preferred-media-players \ | sed -e "s:[],'\[]::g"` mkdir -p $UCS_CACHE touch $UCS_CURRENT_PLAYER_FILE UCS_CURRENT_PLAYER=`cat $UCS_CURRENT_PLAYER_FILE` function initialize-current-player { # if ! echo $UCS_INTERESTED_PLAYERS | grep -q $UCS_CURRENT_PLAYER ; then # UCS_CURRENT_PLAYER=`echo $UCS_PREFFERED_PLAYERS | grep -o "^\S*[^.]"` UCS_CURRENT_PLAYER=`echo $UCS_CURRENT_PLAYER | sed "s/\s//g"` echo Current player now is '"'$UCS_CURRENT_PLAYER'"' fi } # function player-next { initial_player=$UCS_CURRENT_PLAYER for player in $UCS_INTERESTED_PLAYERS do if [ -z "$first_player" ]; then first_player=$player fi if [ "$previous_player" == "$UCS_CURRENT_PLAYER" ]; then UCS_CURRENT_PLAYER=$player break fi previous_player=$player done if [ "$initial_player" == "$UCS_CURRENT_PLAYER" ]; then UCS_CURRENT_PLAYER=$first_player fi echo $UCS_CURRENT_PLAYER > $UCS_CURRENT_PLAYER_FILE } # function player-previous { initial_player=$UCS_CURRENT_PLAYER for player in $UCS_INTERESTED_PLAYERS do if [ -z "$first_player" ]; then first_player=$player fi if [ "$player" == "$UCS_CURRENT_PLAYER" ]; then UCS_CURRENT_PLAYER=$previous_player fi previous_player=$player done if [ -z "$UCS_CURRENT_PLAYER" ]; then UCS_CURRENT_PLAYER=$previous_player fi echo $UCS_CURRENT_PLAYER > $UCS_CURRENT_PLAYER_FILE }
#, , , #, : UCS_SYSTEM_WIDE_LAUNCHERS_PATH=/usr/share/applications UCS_LAUNCHERS_PATH=~/.local/share/applications # function player-launcher { name=$1 launcher=$UCS_LAUNCHERS_PATH/$name system_wide_launcher=$UCS_SYSTEM_WIDE_LAUNCHERS_PATH/$name if [ -f "$launcher" ]; then echo $launcher else echo $system_wide_launcher fi } # function player-display-name { name=$1 launcher=`player-launcher $name` if [ -f "$launcher" ]; then cat $launcher | grep -m 1 "^Name=" \ | sed "s/Name=//" else echo $player | sed "s/.desktop//" fi } # , function current-player-icon { launcher=`player-launcher $UCS_CURRENT_PLAYER` if [ -f "$launcher" ]; then cat $launcher | grep "Icon=" \ | sed "s/Icon=//" fi } # function show-current-player { echo Curent player '"'$UCS_CURRENT_PLAYER'"' for player in $UCS_INTERESTED_PLAYERS do if [ $player == $UCS_CURRENT_PLAYER ]; then players=$players* fi player_name=`player-display-name $player` players=$players$player_name\\n done icon=`current-player-icon` if ! [ -z $icon ]; then icon="-i $icon" fi echo Icon is "$icon" notify-send "Players:" "$players" $icon -t 1 }
gdbus call --session --dest com.canonical.indicator.sound --object-path /com/canonical/indicator/sound \ --method org.gtk.Actions.Describe vkcomvkcom.desktop
sudo apt-get install compizconfig-settings-manager
Source: https://habr.com/ru/post/203504/
All Articles