본문 바로가기
오픈소스 읽기 (OLD)/모던 IPC 시스템 - D-Bus

번외. 주요 D-Bus 프로토콜 스펙들

by 커널패닉 2021. 4. 13.
반응형

유투브: The mind behind Linux Linus Torvalds

위 이미지는 리눅스 그놈 데스크탑에서 파이어폭스 브라우저로 유투브를 재생하는 모습이다. 그런데 한 가지 신기한게 있다. 상단 드롭다운 메뉴에 현재 재생하는 영상을 정지하거나 다음/이전 영상 재생을 할 수 있는 컨트롤 패널이 생겼다. 그놈 데스크탑과 파이어폭스는 완전히 다른 두 앱이지만, 서로간의 커넥션이 이뤄진 것이다. 파이어폭스만 그럴까? vlc, totem, lollypop 등 리눅스에서 사용 가능한 대부분의 미디어 플레이어로 영상을 재생하면, 그놈 데스크탑에는 파이어폭스와 동일한 컨프롤 패널이 생성된다. 그놈 데스크탑이 그 많은 미디어 플레이어들과 협업을 해서, 커넥션을 형성한 것일까? 그렇다면 누군가 새로운 미디어 플레이어를 개발한다면, 그놈 데스크탑은 커넥션을 형성하기 위해 새로운 작업을 해야 할까?

보다 효율적이고 확장 가능한 D-Bus의 사용을 위해서 freedesktop.org를 중심으로 리눅스 커뮤니티에서는 몇 가지 스펙들을 정의해 두었다. 위에서 든 예에서 볼 수 있듯이 미디어 플레이어의 경우에는 Mpris(Media Player Remote Interfacing Specification)를 두어서, 새로운 미디어 플레이어가 제작되더라도 동일한 인터페이스로 컨트롤이 가능하게 만들었다. 따라서 이러한 스펙들을 준수한다면, 기존 리눅스 생태계의 자산들을 적극 활용하면서 적은 노력으로 효율 좋은 프로그램을 개발할 수 있다. 또한 이렇게 개발된 앱들은 다시 리눅스 생태계의 자산이 될 수 있다. 이번 장에서는 주로 사용되는 D-Bus 스펙들을 훑고 지나가려 한다.

 

1. Mpris

Mpirs(Media Player Remote Interfacing Specification)는 미디어 플레이어의 동작을 컨트롤 하기 위한 D-Bus 스펙이다. 우선 Mpris 스펙은 다음과 같은 규칙을 갖는다.

  • Bus name은 반드시 "org.mpris.MediaPlayer2"로 시작한다.
    ex) org.mpris.MediaPlayer2.vlc
  • Object Path는 반드시 /org/mpris/MediaPlayer2로 시작한다.
  • 반드시 "org.mpris.MediaPlayer2"와 "org.mpris.MediaPlayer2.Player" Interface를 구현한다.
  • 필요하다면 "org.mpris.MediaPlayer2.TrackList"와 "org.mpris.MediaPlayer2.TrackList" Interface를 구현한다.

각 Interface는 다시 상세한 Method, Signal 규칙을 가지고 있다. Mpris에 대해 더 자세히 알고 싶다면 아래 링크를 참조하자.

 

Interface Link
org.mpris.MediaPlayer2 specifications.freedesktop.org/mpris-spec/latest/Media_Player.html
org.mpris.MediaPlayer2.Player specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html
org.mpris.MediaPlayer2.TrackList specifications.freedesktop.org/mpris-spec/latest/Track_List_Interface.html
org.mpris.MediaPlayer2.TrackList specifications.freedesktop.org/mpris-spec/latest/Playlists_Interface.html

2. Notification

알람을 처리하는 일은 중요하다. 파일 용량이 가득 차거나, USB가 연결되거나, 캘린더의 일정이 다가오면 리눅스에는 알람이 발생한다. 그런데 알람을 호출하는 앱과 알람을 받고 노티를 띄워주는 앱은 고정되어 있지 않다. 만약 최신 버전의 우분투 및 그놈 데스크탑 계열의 배포판을 사용한다면, notification-daemon이 알람을 수신해서, 사용자들에게 노티를 제공한다. 만약 xfce를 사용한다면, xfce4-notifyd이 노티를 처리한다. 알람을 처리하기 위한 notification 서비스의 스펙은 다음과 같다.

  • Bus name은 "org.freedesktop.Notifications"로 한다. 기존에 동일한 Bus name을 가진 서비스가 있다면, 해당 서비스를 비활성화 한다.
  • Object Path는 반드시 "/org/freedesktop/Notifications"로 한다.
  • Interface는 반드시 "org.freedesktop.Notifications"를 구현한다.

Interface는 다음 메소드를 제공한다.

  Method
Method GetCapabilities
Method CloseNotification
Method GetServerInformation
Signal NotificationClosed

 

스펙과 관련한 보다 자세한 설명은 아래 문서를 참조하자.

specifications.freedesktop.org/notification-spec/notification-spec-latest.html#protocol

 

Desktop Notifications Specification

This is a draft standard for a desktop notifications service, through which applications can generate passive popups to notify the user in an asynchronous manner of events. This specification explicitly does not include other types of notification presenta

specifications.freedesktop.org

developer.gnome.org/notification-spec/

반응형

'오픈소스 읽기 (OLD) > 모던 IPC 시스템 - D-Bus' 카테고리의 다른 글

2. D-Bus 사용방법  (4) 2021.04.11
1. D-Bus 기초  (2) 2021.03.27
0. 전통적인 리눅스/Unix IPC 방법들  (0) 2021.03.22