ÏàʶLinuxÏÂGDMµÄÀúÊ·Éú³¤¼°Î´À´Ç÷ÊÆ
¡¶LinuxÏÂGDMµÄÀúÊ·Éú³¤¼°Î´À´Ç÷ÊÆ¡·
ÔÚLinux²Ù×÷ϵͳÖУ¬GDM£¨GNOME Display Manager£©ÊÇÒ»¿î³£ÓõÄÏÔʾÖÎÀíÆ÷£¬ÓÃÓڵǼºÍÖÎÀíÓû§»á»°¡£ËüÔçÏÈÊÇΪGNOME×ÀÃæÇéÐζøÉè¼ÆµÄ£¬µ«ØʺóÒ²±»ÆäËû×ÀÃæÇéÐÎËù½ÓÄÉ¡£±¾ÎĽ«¶ÔGDMµÄÀúÊ·Éú³¤¾ÙÐÐÊáÀí£¬Í¬Ê±Ì½ÌÖÆäδÀ´µÄÉú³¤Ç÷ÊÆ£¬²¢ÌṩһЩÏêϸµÄ´úÂëʾÀýÒÔ×ÊÖú¶ÁÕ߸üºÃµØÏàʶÕâÒ»×é¼þ¡£
Ò»¡¢ÀúÊ·Éú³¤
GDM×îÔç·ºÆðÔÚ1999Ä꣬×÷ΪGNOME 1.0°æ±¾µÄÒ»²¿·Ö¡£×î³õ£¬ËüµÄ¹¦Ð§Ö÷ÒªÊÇÌṩһ¸öÓѺõĽçÃ湩Óû§µÇ¼£¬²¢ÔÚÓû§Ñé֤ͨʺóÆô¶¯X»á»°¡£Ëæ×ÅGNOME×ÀÃæÇéÐεÄÒ»Ö±Éú³¤£¬GDMÒ²Öð½¥ÔöÌíÁËÐí¶àÐµĹ¦Ð§£¬Èç×Ô½ç˵Ö÷Ìâ¡¢»á»°ÖÎÀí¡¢ÆÁÄ»±£»¤³ÌÐòµÈ¡£
Ëæ×Åʱ¼äµÄÍÆÒÆ£¬GDMµÄ´úÂëÖð½¥±äµÃÖØ´ó£¬Í¬Ê±Ò²Êܵ½ÁËÀ´×ÔÆäËûÏÔʾÖÎÀíÆ÷µÄ¾ºÕù£¬ÈçKDM¡¢LightDMµÈ¡£È»¶ø£¬ÓÉÓÚÆäÎȹÌÐԺͶÔGNOMEÌØÕ÷µÄÓÅÒìÖ§³Ö£¬GDMÈÔÈ»ÊÇÐí¶àLinux¿¯ÐаæµÄĬÈÏÏÔʾÖÎÀíÆ÷£¬ÈçUbuntu¡¢FedoraµÈ¡£
¶þ¡¢Î´À´Ç÷ÊÆ
δÀ´£¬Ëæ×ÅLinuxÉú̬ϵͳµÄÒ»Ö±Éú³¤£¬GDMÒ²½«¼ÌÐøÑݽø¡£Ò»Ð©¿ÉÄܵÄÉú³¤Ç÷ÊÆ°üÀ¨£º
ÒýÈë¸ü¶àµÄͼÐÎÌØЧºÍ¶¯»Ð§¹û£¬ÌáÉýÓû§ÌåÑ飻
Ö§³Ö¸ü¶àµÄÈÏÖ¤ÒªÁ죬ÈçÉúÎïʶ±ð¡¢ÖÇÄÜ¿¨µÈ£»
ˢлỰÖÎÀí¹¦Ð§£¬Ê¹Óû§Äܹ»ÇáËÉÇл»²î±ðµÄ×ÀÃæÇéÐλò´°¿ÚÖÎÀíÆ÷£»
ÓÅ»¯×ÊԴʹÓã¬Ìá¸ßÐÔÄܺÍÎȹÌÐÔ¡£
Èý¡¢´úÂëʾÀý
ÒÔÏÂÊÇÒ»¸ö¼òÆӵĴúÂëʾÀý£¬ÑÝʾÔõÑùʹÓÃGDMµÄD-Bus½Ó¿ÚÀ´ÅÌÎÊÄ¿½ñÓû§ÊÇ·ñÒѵǼ£º
import dbus bus = dbus.SystemBus() proxy = bus.get_object('org.gnome.DisplayManager', '/org/gnome/DisplayManager/Manager') interface = dbus.Interface(proxy, 'org.gnome.DisplayManager.Manager') is_user_logged_in = interface.IsSeatActive('seat0') if is_user_logged_in: print("Ä¿½ñÓû§ÒѵǼ") else: print("Ä¿½ñÓû§Î´µÇ¼")
µÇ¼ºó¸´ÖÆ
ͨ¹ýÕâ¶Î´úÂ룬Äã¿ÉÒÔʹÓÃD-Bus½Ó¿ÚÓëGDM¾ÙÐÐͨѶ£¬ÅÌÎÊÄ¿½ñÓû§µÄµÇ¼״̬¡£
×ܽ᣺
ͨ¹ý¶ÔLinuxÏÂGDMµÄÀúÊ·Éú³¤ºÍδÀ´Ç÷ÊƵÄ̽ÌÖ£¬ÎÒÃÇ¿ÉÒÔ¿´µ½ÕâÒ»ÏÔʾÖÎÀíÆ÷ÔÚÒ»Ö±ÑݱäºÍÍêÉÆ£¬ÒÔÖª×ãÓû§µÄÐèÇó¡£Î´À´£¬Ëæ×ÅÊÖÒÕµÄһֱǰ½ø£¬GDM½«½øÒ»²½ÌáÉýÓû§ÌåÑéºÍϵͳÐÔÄÜ£¬³ÉΪLinux×ÀÃæÇéÐÎÖеÄÖ÷ÒªÒ»»·¡£Ï£Íû±¾ÎĶÔÄú¶ÔGDMÓÐËùÆô·¢£¬Ò²½Ó´ýÄúÉîÈëÑо¿ºÍ̽ÌÖ¸ÃÁìÓòµÄ¸ü¶àÄÚÈÝ¡£
ÒÔÉϾÍÊÇÏàʶLinuxÏÂGDMµÄÀúÊ·Éú³¤¼°Î´À´Ç÷ÊƵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡