diff --git a/pinxi b/pinxi index 1e55509..03da52d 100755 --- a/pinxi +++ b/pinxi @@ -50,8 +50,8 @@ use POSIX qw(ceil uname strftime ttyname); ## INXI INFO ## my $self_name='pinxi'; my $self_version='3.3.31'; -my $self_date='2023-12-13'; -my $self_patch='26'; +my $self_date='2023-12-14'; +my $self_patch='27'; ## END INXI INFO ## my ($b_pledge,@pledges); @@ -593,7 +593,7 @@ sub set_sudo { $sudoas = "$path -n "; } elsif (!$force{'no-sudo'} && ($path = check_program('sudo'))){ - my @data = program_data('sudo'); + my @data = ProgramData::full('sudo'); $data[1] =~ s/^([0-9]+\.[0-9]+).*/$1/; # print "sudo v: $data[1]\n"; $sudoas = "$path -n " if is_numeric($data[1]) && $data[1] >= 1.7; @@ -2169,7 +2169,9 @@ sub system_data { ['lsusb',''], ['lsusb','-t'], ['lsusb','-v'], + ['ps',''], ['ps','aux'], + ['ps','auxww'], ['ps','-e'], ['ps','-p 1'], ['runlevel',''], @@ -4001,516 +4003,6 @@ sub load_json { eval $end if $b_log; } -# returns array of: 0: program print name 1: program version -# args: 0: program values id; 1: program version string; -# 2: $extra level. Note that StartClient runs BEFORE -x levels are set! -# Only use this function when you only need the name/version data returned -sub program_data { - eval $start if $b_log; - my ($values_id,$version_id,$level) = @_; - my (@data,$path,@program_data); - $level = 0 if !$level; - # print "val_id: $values_id ver_id:$version_id lev:$level ex:$extra\n"; - $version_id = $values_id if !$version_id; - @data = program_values($values_id); - if ($data[3]){ - $program_data[0] = $data[3]; - # programs that have no version method return 0 0 for index 1 and 2 - if ($extra >= $level && $data[1] && $data[2]){ - $program_data[1] = program_version($version_id,$data[0], - $data[1],$data[2],$data[5],$data[6],$data[7],$data[8]); - } - } - $program_data[0] ||= ''; - $program_data[1] ||= ''; - eval $end if $b_log; - return @program_data; -} - -# It's almost 1000 times slower to load these each time program_values is called!! -# returns: 0: desktop/app command for --version; 1: search string; -# 2: space print number; 3: [optional] version arg: -v, version, etc; -# 4: [optional] exit first find 0/1; 5: [optional] 0/1 stderr output; -# 6: replace regex; 7: extra data -sub set_program_values { - %program_values = ( - ## Clients ## - 'bitchx' => ['bitchx',2,'','BitchX',1,0,0,'',''],# special - 'finch' => ['finch',2,'-v','Finch',1,1,0,'',''], - 'gaim' => ['[0-9.]+',2,'-v','Gaim',0,1,0,'',''], - 'ircii' => ['[0-9.]+',3,'-v','ircII',1,1,0,'',''], - 'irssi' => ['irssi',2,'-v','Irssi',1,1,0,'',''], - 'irssi-text' => ['irssi',2,'-v','Irssi',1,1,0,'',''], - 'konversation' => ['konversation',2,'-v','Konversation',0,0,0,'',''], - 'kopete' => ['Kopete',2,'-v','Kopete',0,0,0,'',''], - 'kvirc' => ['[0-9.]+',2,'-v','KVIrc',0,0,1,'',''], # special - 'pidgin' => ['[0-9.]+',2,'-v','Pidgin',0,1,0,'',''], - 'quassel' => ['',1,'-v','Quassel [M]',0,0,0,'',''], # special - 'quasselclient' => ['',1,'-v','Quassel',0,0,0,'',''],# special - 'quasselcore' => ['',1,'-v','Quassel (core)',0,0,0,'',''],# special - 'gribble' => ['^Supybot',2,'--version','Gribble',1,0,0,'',''],# special - 'limnoria' => ['^Supybot',2,'--version','Limnoria',1,0,0,'',''],# special - 'supybot' => ['^Supybot',2,'--version','Supybot',1,0,0,'',''],# special - 'weechat' => ['[0-9.]+',1,'-v','WeeChat',1,0,0,'',''], - 'weechat-curses' => ['[0-9.]+',1,'-v','WeeChat',1,0,0,'',''], - 'xchat-gnome' => ['[0-9.]+',2,'-v','X-Chat-Gnome',1,1,0,'',''], - 'xchat' => ['[0-9.]+',2,'-v','X-Chat',1,1,0,'',''], - ## Desktops / wm / compositors ## - '2bwm' => ['^2bwm',0,'0','2bWM',0,1,0,'',''], # unverified/based on mcwm - '3dwm' => ['^3dwm',0,'0','3Dwm',0,1,0,'',''], # unverified - '5dwm' => ['^5dwm',0,'0','5Dwm',0,1,0,'',''], # unverified - '9wm' => ['^9wm',3,'-version','9wm',0,1,0,'',''], - 'aewm' => ['^aewm',3,'--version','aewm',0,1,0,'',''], - 'aewm++' => ['^Version:',2,'-version','aewm++',0,1,0,'',''], - 'afterstep' => ['^afterstep',3,'--version','AfterStep',0,1,0,'',''], - 'amiwm' => ['^amiwm',0,'0','AmiWM',0,1,0,'',''], # no version - 'antiwm' => ['^antiwm',0,'0','AntiWM',0,1,0,'',''], # no version known - 'asc' => ['^asc',0,'0','asc',0,1,0,'',''], - 'awc' => ['^awc',0,'0','awc',0,1,0,'',''], # unverified - 'awesome' => ['^awesome',2,'--version','awesome',0,1,0,'',''], - 'beryl' => ['^beryl',0,'0','Beryl',0,1,0,'',''], # unverified; legacy - 'blackbox' => ['^Blackbox',2,'--version','Blackbox',0,1,0,'',''], - 'bspwm' => ['^\S',1,'-v','bspwm',0,1,0,'',''], - 'budgie-desktop' => ['^budgie-desktop',2,'--version','Budgie',0,1,0,'',''], - 'budgie-wm' => ['^budgie',0,'0','budgie-wm',0,1,0,'',''], - 'cage' => ['^cage',0,'0','Cage',0,1,0,'',''], # unverified - 'cagebreak' => ['^Cagebreak',3,'-v','Cagebreak',0,1,0,'',''], - 'calmwm' => ['^calmwm',0,'0','CalmWM',0,1,0,'',''], # unverified - 'cardboard' => ['^cardboard',0,'0','Cardboard',0,1,0,'',''], # unverified - 'catwm' => ['^catwm',0,'0','catwm',0,1,0,'',''], # unverified - 'cde' => ['^cde',0,'0','CDE',0,1,0,'',''], # unverified - 'chameleonwm' => ['^chameleon',0,'0','ChameleonWM',0,1,0,'',''], # unverified - 'cinnamon' => ['^cinnamon',2,'--version','Cinnamon',0,1,0,'',''], - 'clfswm' => ['^clsfwm',0,'0','clfswm',0,1,0,'',''], # no version - 'comfc' => ['^comfc',0,'0','comfc',0,1,0,'',''], # unverified - 'compiz' => ['^compiz',2,'--version','Compiz',0,1,0,'',''], - 'compton' => ['^\d',1,'--version','Compton',0,1,0,'',''], - 'cosmic-comp' => ['^cosmic-comp',0,'0','cosmic-comp',0,1,0,'',''], # unverified - 'ctwm' => ['^\S',1,'-version','ctwm',0,1,0,'',''], - 'cwm' => ['^cwm',0,'0','CWM',0,1,0,'',''], # no version - 'dawn' => ['^dawn',1,'-v','dawn',0,1,1,'^dawn-',''], # to stderr, not verified - 'dcompmgr' => ['^dcompmgr',0,'0','dcompmgr',0,1,0,'',''], # unverified - 'deepin' => ['^Version',2,'file','Deepin',0,100,'=','','/etc/deepin-version'], # special - 'deepin-metacity' => ['^metacity',2,'--version','Deepin-Metacity',0,1,0,'',''], - 'deepin-mutter' => ['^mutter',2,'--version','Deepin-Mutter',0,1,0,'',''], - 'deepin-wm' => ['^gala',0,'0','DeepinWM',0,1,0,'',''], # no version - 'dusk' => ['^dusk',1,'-v','dusk',0,1,1,'^dusk-',''], # to stderr, not verified - 'dwc' => ['^dwc',0,'0','dwc',0,1,0,'',''], # unverified - 'dwl' => ['^dwl',0,'0','dwl',0,1,0,'',''], # unverified - 'dwm' => ['^dwm',1,'-v','dwm',0,1,1,'^dwm-',''], - 'echinus' => ['^echinus',1,'-v','echinus',0,1,1,'',''], # echinus-0.4.9 (c)... - # only listed here for compositor values, version data comes from xprop - 'enlightenment' => ['^enlightenment',0,'0','enlightenment',0,1,0,'',''], # no version, yet? - 'epd-wm' => ['^epd-wm',0,'0','epd-wm',0,1,0,'',''], # unverified - 'evilwm' => ['evilwm',3,'-V','evilwm',0,1,0,'',''],# might use full path in match - 'feathers' => ['^feathers',0,'0','feathers',0,1,0,'',''], # unverified - 'fenestra' => ['^fenestra',0,'0','fenestra',0,1,0,'',''], # unverified - 'fireplace' => ['^fireplace',0,'0','fireplace',0,1,0,'',''], # unverified - 'fluxbox' => ['^fluxbox',2,'-v','Fluxbox',0,1,0,'',''], - 'flwm' => ['^flwm',0,'0','FLWM',0,0,1,'',''], # no version - # openbsd changed: version string: [FVWM[[main] Fvwm.. sigh, and outputs to stderr. Why? - 'fvwm' => ['^fvwm',2,'-version','FVWM',0,1,0,'',''], - 'fvwm1' => ['^Fvwm',3,'-version','FVWM1',0,1,1,'',''], - 'fvwm2' => ['^fvwm',2,'--version','FVWM2',0,1,0,'',''], - 'fvwm3' => ['^fvwm',2,'--version','FVWM3',0,1,0,'',''], - 'fvwm95' => ['^fvwm',2,'--version','FVWM95',0,1,1,'',''], - 'fvwm-crystal' => ['^fvwm',2,'--version','FVWM-Crystal',0,0,0,'',''], # for print name fvwm - 'gala' => ['^gala',0,'0','gala',0,1,0,'',''], # pantheon wm: super slow result, 2, '--version' works? - 'gamescope' => ['^gamescope',0,'0','Gamescope',0,1,0,'',''], # unverified - 'glass' => ['^glass',3,'-v','Glass',0,1,0,'',''], - 'gnome' => ['^gnome',3,'--version','GNOME',0,1,0,'',''], # no version, print name - 'gnome-about' => ['^gnome',3,'--version','GNOME',0,1,0,'',''], - 'gnome-shell' => ['^gnome',3,'--version','gnome-shell',0,1,0,'',''], - 'greenfield' => ['^greenfield',0,'0','Greenfield',0,1,0,'',''], # unverified - 'grefson' => ['^grefson',0,'0','Grefson',0,1,0,'',''], # unverified - 'hackedbox' => ['^hackedbox',2,'-version','HackedBox',0,1,0,'',''], # unverified, assume blackbox - # note, herbstluftwm when launched with full path returns full path in version string - 'herbstluftwm' => ['herbstluftwm',2,'--version','herbstluftwm',0,1,0,'',''], - 'hikari' => ['^hikari',0,'0','hikari',0,1,0,'',''], # unverified - 'hopalong' => ['^hopalong',0,'0','Hopalong',0,1,0,'',''], # unverified - 'hyprctl' => ['^Tag:',2,'version','Hyprland',0,1,0,'',''], # method to get hyprland version - 'hyprland' => ['^hyprland',0,'0','Hyprland',0,1,0,'',''], # uses hyprctl for version - 'i3' => ['^i3',3,'--version','i3',0,1,0,'',''], - 'icewm' => ['^icewm',2,'--version','IceWM',0,1,0,'',''], - 'inaban' => ['^inaban',0,'0','inaban',0,1,0,'',''], # unverified - 'instantwm' => ['^instantwm',1,'-v','instantWM',0,1,1,'^instantwm-?(instantos-?)?',''], - 'ion3' => ['^ion3',0,'--version','Ion3',0,1,0,'',''], # unverified; also shell called ion - 'japokwm' => ['^japokwm',0,'0','japokwm',0,1,0,'',''], # unverified - 'jbwm' => ['jbwm',3,'-v','JBWM',0,1,0,'',''], # might use full path in match - 'jwm' => ['^jwm',2,'--version','JWM',0,1,0,'',''], - 'kded' => ['^KDE( Development Platform)?:',2,'--version','KDE',0,1,0,'\sDevelopment Platform',''], - 'kded1' => ['^KDE( Development Platform)?:',2,'--version','KDE',0,1,0,'\sDevelopment Platform',''], - 'kded2' => ['^KDE( Development Platform)?:',2,'--version','KDE',0,1,0,'\sDevelopment Platform',''], - 'kded3' => ['^KDE( Development Platform)?:',2,'--version','KDE',0,1,0,'\sDevelopment Platform',''], - 'kded4' => ['^KDE( Development Platform)?:',2,'--version','KDE',0,1,0,'\sDevelopment Platform',''], - 'kiwmi' => ['^kwimi',0,'0','kiwmi',0,1,0,'',''], # unverified - 'ksmcon' => ['^ksmcon',0,'0','ksmcon',0,1,0,'',''],# no version - 'kwin' => ['^kwin',0,'0','kwin',0,1,0,'',''],# no version - 'kwin_wayland' => ['^kwin_wayland',0,'0','kwin_wayland',0,1,0,'',''],# no version - 'kwin_x11' => ['^kwin_x11',0,'0','kwin_x11',0,1,0,'',''],# no version - 'kwinft' => ['^kwinft',0,'0','KWinFT',0,1,0,'',''], # unverified - 'labwc' => ['^labwc',0,'0','LabWC',0,1,0,'',''], # unverified - 'laikawm' => ['^laikawm',0,'0','LaikaWM',0,1,0,'',''], # unverified - 'larswm' => ['^larswm',2,'-v','larswm',0,1,1,'',''], - 'leftwm' => ['^leftwm',0,'0','LeftWM',0,1,0,'',''],# no version, in CHANGELOG - 'liri' => ['^liri',0,'0','liri',0,1,0,'',''], - 'lipstick' => ['^lipstick',0,'0','Lipstick',0,1,0,'',''], # unverified - 'liri' => ['^liri',0,'0','liri',0,1,0,'',''], # unverified - 'lumina-desktop' => ['^\S',1,'--version','Lumina',0,1,1,'',''], - 'lwm' => ['^lwm',0,'0','lwm',0,1,0,'',''], # no version - 'lxpanel' => ['^lxpanel',2,'--version','LXDE',0,1,0,'',''], - # command: lxqt-panel - 'lxqt-panel' => ['^lxqt-panel',2,'--version','LXQt',0,1,0,'',''], - 'lxqt-variant' => ['^lxqt-panel',0,'0','LXQt-Variant',0,1,0,'',''], - 'lxsession' => ['^lxsession',0,'0','lxsession',0,1,0,'',''], - 'mahogany' => ['^mahogany',0,'0','Mahogany',0,1,0,'',''], # unverified - 'manokwari' => ['^manokwari',0,'0','Manokwari',0,1,0,'',''], - 'marina' => ['^marina',0,'0','Marina',0,1,0,'',''], # unverified - 'marco' => ['^marco',2,'--version','marco',0,1,0,'',''], - 'matchbox' => ['^matchbox',0,'0','Matchbox',0,1,0,'',''], - 'matchbox-window-manager' => ['^matchbox',2,'--help','Matchbox',0,0,0,'',''], - 'mate-about' => ['^MATE[[:space:]]DESKTOP',-1,'--version','MATE',0,1,0,'',''], - # note, mate-session when launched with full path returns full path in version string - 'mate-session' => ['mate-session',-1,'--version','MATE',0,1,0,'',''], - 'maze' => ['^maze',0,'0','Maze',0,1,0,'',''], # unverified - 'mcwm' => ['^mcwm',0,'0','mcwm',0,1,0,'',''], # unverified/see 2bwm - 'metacity' => ['^metacity',2,'--version','Metacity',0,1,0,'',''], - 'metisse' => ['^metisse',0,'0','metisse',0,1,0,'',''], - 'mini' => ['^Mini',5,'--version','Mini',0,1,0,'',''], - 'mir' => ['^mir',0,'0','mir',0,1,0,'',''],# unverified - 'moblin' => ['^moblin',0,'0','moblin',0,1,0,'',''],# unverified - 'monsterwm' => ['^monsterwm',0,'0','monsterwm',0,1,0,'',''],# unverified - 'motorcar' => ['^motorcar',0,'0','motorcar',0,1,0,'',''],# unverified - 'muffin' => ['^muffin',2,'--version','Muffin',0,1,0,'',''], - 'musca' => ['^musca',0,'-v','Musca',0,1,0,'',''], # unverified - 'mutter' => ['^mutter',2,'--version','Mutter',0,1,0,'',''], - 'mwm' => ['^mwm',0,'0','MWM',0,1,0,'',''],# no version - 'nawm' => ['^nawm',0,'0','nawm',0,1,0,'',''],# unverified - 'newm' => ['^newm',0,'0','newm',0,1,0,'',''], # unverified - 'notion' => ['^.',1,'--version','Notion',0,1,0,'',''], - 'nscde' => ['^nscde',0,'0','NsCDE',0,1,0,'',''], # unverified - 'nucleus' => ['^nucleus',0,'0','Nucleus',0,1,0,'',''], # unverified - 'openbox' => ['^openbox',2,'--version','Openbox',0,1,0,'',''], - 'orbital' => ['^orbital',0,'0','Orbital',0,1,0,'',''],# unverified - 'orbment' => ['^orbment',0,'0','orbment',0,1,0,'',''], # unverified - 'pantheon' => ['^pantheon',0,'0','Pantheon',0,1,0,'',''],# no version - 'papyros' => ['^papyros',0,'0','papyros',0,1,0,'',''],# no version - 'pekwm' => ['^pekwm',3,'--version','PekWM',0,1,0,'',''], - 'penrose' => ['^penrose',0,'0','Penrose',0,1,0,'',''],# no version? - 'perceptia' => ['^perceptia',0,'0','perceptia',0,1,0,'',''], - 'phoc' => ['^phoc',0,'0','phoc',0,1,0,'',''], # unverified - 'picom' => ['^\S',1,'--version','Picom',0,1,0,'^v',''], - 'plasmashell' => ['^plasmashell',2,'--version','KDE Plasma',0,1,0,'',''], - 'pywm' => ['^pywm',0,'0','pywm',0,1,0,'',''], # unverified - 'qtile' => ['^',1,'--version','Qtile',0,1,0,'',''], - 'qvwm' => ['^qvwm',0,'0','qvwm',0,1,0,'',''], # unverified - 'razor-session' => ['^razor',0,'0','Razor-Qt',0,1,0,'',''], - 'ratpoison' => ['^ratpoison',2,'--version','Ratpoison',0,1,0,'',''], - 'river' => ['^river',0,'0','River',0,1,0,'',''], # unverified - 'rootston' => ['^rootston',0,'0','rootston',0,1,0,'',''], # unverified, wlroot ref - 'rustland' => ['^rustland',0,'0','rustland',0,1,0,'',''], # unverified - 'sawfish' => ['^sawfish',3,'--version','Sawfish',0,1,0,'',''], - 'scrotwm' => ['^scrotwm.*welcome.*',5,'-v','scrotwm',0,1,1,'',''], - 'simulavr' => ['simulavr^',0,'0','SimulaVR',0,1,0,'',''], # unverified - 'skylight' => ['^skylight',0,'0','Skylight',0,1,0,'',''], # unverified - 'smithay' => ['^smithay',0,'0','Smithay',0,1,0,'',''], # unverified - 'sommelier' => ['^sommelier',0,'0','sommelier',0,1,0,'',''], # unverified - 'snapwm' => ['^snapwm',0,'0','snapwm',0,1,0,'',''], # unverified - 'spectrwm' => ['^spectrwm.*welcome.*wm',5,'-v','spectrwm',0,1,1,'',''], - # out of stump, 2 --version, but in tries to start new wm instance endless hang - 'stumpwm' => ['^SBCL',0,'--version','StumpWM',0,1,0,'',''], # hangs when run in wm - 'surfaceflinger' => ['surfaceflinger^',0,'0','SurfaceFlinger',0,1,0,'',''], # Android, unverified - 'sway' => ['^sway',3,'-v','Sway',0,1,0,'',''], - 'swayfx' => ['^sway',3,'-v','SwayFX',0,1,0,'',''], # not sure if safe - 'swc' => ['^swc',0,'0','swc',0,1,0,'',''], # unverified - 'swvkc' => ['^swvkc',0,'0','swvkc',0,1,0,'',''], # unverified - 'tabby' => ['^tabby',0,'0','Tabby',0,1,0,'',''], # unverified - 'taiwins' => ['^taiwins',0,'0','taiwins',0,1,0,'',''], # unverified - 'tinybox' => ['^tinybox',0,'0','tinybox',0,1,0,'',''], # unverified - 'tinywl' => ['^tinywl',0,'0','TinyWL',0,1,0,'',''], # unverified - 'tinywm' => ['^tinywm',0,'0','TinyWM',0,1,0,'',''], # no version - 'trinkster' => ['^trinkster',0,'0','Trinkster',0,1,0,'',''], # unverified - 'tvtwm' => ['^tvtwm',0,'0','tvtwm',0,1,0,'',''], # unverified - 'twin' => ['^Twin:',2,'--version','Twin',0,0,0,'',''], - 'twm' => ['^twm',0,'0','TWM',0,1,0,'',''], # no version - 'ukui' => ['^ukui-session',2,'--version','UKUI',0,1,0,'',''], - 'ukwm' => ['^ukwm',2,'--version','ukwm',0,1,0,'',''], - 'unagi' => ['^\S',1,'--version','unagi',0,1,0,'',''], - 'unity' => ['^unity',2,'--version','Unity',0,1,0,'',''], - 'unity-system-compositor' => ['^unity-system-compositor',2,'--version', - 'unity-system-compositor (mir)',0,0,0,'',''], - 'uwm' => ['^uwm',0,'0','UWM',0,1,0,'',''], # unverified - 'velox' => ['^velox',0,'0','Velox',0,1,0,'',''], # unverified - 'vimway' => ['^vimway',0,'0','vimway',0,1,0,'',''], # unverified - 'vivarium' => ['^vivarium',0,'0','Vivarium',0,1,0,'',''], # unverified - 'wavy' => ['^wavy',0,'0','wavy',0,1,0,'',''], # unverified - 'waybox' => ['^way',0,'0','waybox',0,1,0,'',''], # unverified - 'waycooler' => ['^way',3,'--version','way-cooler',0,1,0,'',''], - 'way-cooler' => ['^way',3,'--version','way-cooler',0,1,0,'',''], - 'wayfire' => ['^\d',1,'--version','wayfire',0,1,0,'',''], # -version/--version - 'wayhouse' => ['^wayhouse',0,'0','wayhouse',0,1,0,'',''], # unverified - 'waymonad' => ['^waymonad',0,'0','waymonad',0,1,0,'',''], # unverified - 'westeros' => ['^westeros',0,'0','westeros',0,1,0,'',''], # unverified - 'westford' => ['^westford',0,'0','westford',0,1,0,'',''], # unverified - 'weston' => ['^weston',0,'0','Weston',0,1,0,'',''], # unverified - 'windowlab' => ['^windowlab',2,'-about','WindowLab',0,1,0,'',''], - 'wingo' => ['^wingo',0,'0','Wingo',0,1,0,'',''], # unverified - 'wio' => ['^wio',0,'0','Wio',0,1,0,'',''], # unverified - 'wio' => ['^wio\+',0,'0','wio+',0,1,0,'',''], # unverified - 'wm2' => ['^wm2',0,'0','wm2',0,1,0,'',''], # no version - 'wmaker' => ['^Window\s*Maker',-1,'--version','WindowMaker',0,1,0,'',''], - 'wmfs' => ['^wmfs',0,'0','WMFS',0,1,0,'',''], # unverified - 'wmfs2' => ['^wmfs',0,'0','WMFS',0,1,0,'',''], # unverified - 'wmii' => ['^wmii',1,'-v','wmii',0,1,0,'^wmii[234]?-',''], # wmii is wmii3 - 'wmii2' => ['^wmii2',1,'--version','wmii2',0,1,0,'^wmii[234]?-',''], - 'wmx' => ['^wmx',0,'0','wmx',0,1,0,'',''], # no version - 'wxrc' => ['^wx',0,'0','',0,1,0,'WXRC',''], # unverified - 'wxrd' => ['^wx',0,'0','',0,1,0,'WXRD',''], # unverified - 'xcompmgr' => ['^xcompmgr',0,'0','xcompmgr',0,1,0,'',''], # no version - 'xfce-panel' => ['^xfce-panel',2,'--version','Xfce',0,1,0,'',''], - 'xfce4-panel' => ['^xfce4-panel',2,'--version','Xfce',0,1,0,'',''], - 'xfce5-panel' => ['^xfce5-panel',2,'--version','Xfce',0,1,0,'',''], - 'xfdesktop' => ['xfdesktop[[:space:]]version',5,'--version','Xfce',0,1,0,'',''], - # command: xfdesktop - 'xfdesktop-toolkit' => ['Built[[:space:]]with[[:space:]]GTK',4,'--version','Gtk',0,1,0,'',''], - # ' This is xfwm4 version 4.16.1 (revision 5f61a84ad) for Xfce 4.16' - 'xfwm' => ['xfwm[3-8]? version',5,'--version','xfwm',0,1,0,'^^\s+',''],# unverified - 'xfwm4' => ['xfwm4? version',5,'--version','xfwm',0,1,0,'^^\s+',''], - 'xfwm5' => ['xfwm5? version',5,'--version','xfwm',0,1,0,'^^\s+',''], # unverified - 'xmonad' => ['^xmonad',2,'--version','XMonad',0,1,0,'',''], - 'xuake' => ['^xuake',0,'0','xuake',0,1,0,'',''], # unverified - 'yeahwm' => ['^yeahwm',0,'--version','YeahWM',0,1,0,'',''], # unverified - ## Toolkits ## - 'gtk-launch' => ['^\S',1,'--version','GTK',0,1,0,'',''], - 'qmake' => ['^^Using Qt version',4,'--version','Qt',0,0,0,'',''], - 'qtdiag' => ['^qt',2,'--version','Qt',0,1,0,'',''], - ## Display Managers (dm) ## - 'brzdm' => ['^brzdm version',3,'-v','brzdm',0,1,0,'',''], # unverified, slim fork - 'cdm' => ['^cdm',0,'0','CDM',0,1,0,'',''], - # might be xlogin, unknown output for -V - 'clogin' => ['^clogin',0,'-V','clogin',0,1,0,'',''], # unverified, maybe xlogin - 'elogind' => ['^elogind',0,'0','elogind',0,1,0,'',''], - 'emptty' => ['^emptty',0,'0','EMPTTY',0,1,0,'',''], # unverified - 'entrance' => ['^entrance',0,'0','Entrance',0,1,0,'',''], - 'gdm' => ['^gdm',2,'--version','GDM',0,1,0,'',''], - 'gdm3' => ['^gdm',2,'--version','GDM3',0,1,0,'',''], - 'greetd' => ['^greetd',0,'0','greetd',0,1,0,'',''], # no version - 'kdm' => ['^kdm',0,'0','KDM',0,1,0,'',''], - 'kdm3' => ['^kdm',0,'0','KDM',0,1,0,'',''], - 'kdmctl' => ['^kdm',0,'0','KDM',0,1,0,'',''], - 'ldm' => ['^ldm',0,'0','LDM',0,1,0,'',''], - 'lightdm' => ['^lightdm',2,'--version','LightDM',0,1,1,'',''], - 'lxdm' => ['^lxdm',0,'0','LXDM',0,1,0,'',''], - 'ly' => ['^ly',3,'--version','Ly',0,1,0,'',''], - 'mdm' => ['^mdm',0,'0','MDM',0,1,0,'',''], - 'mlogin' => ['^mlogin',0,'0','mlogin',0,1,0,'',''], # unverified - 'nodm' => ['^nodm',0,'0','nodm',0,1,0,'',''], - 'pcdm' => ['^pcdm',0,'0','PCDM',0,1,0,'',''], - 'qingy' => ['^qingy',0,'0','qingy',0,1,0,'',''], # unverified - 'seatd' => ['^seatd',3,'-v','seatd',0,1,0,'',''], - 'sddm' => ['^sddm',0,'0','SDDM',0,1,0,'',''], - 'slim' => ['slim version',3,'-v','SLiM',0,1,0,'',''], - 'slimski' => ['slimski version',3,'-v','slimski',0,1,0,'',''], # slim fork - 'tbsm' => ['^tbsm',0,'0','tbsm',0,1,0,'',''], # unverified - 'tdm' => ['^tdm',0,'0','TDM',0,1,0,'',''], - 'udm' => ['^udm',0,'0','udm',0,1,0,'',''], - 'wdm' => ['^wdm',0,'0','WINGs DM',0,1,0,'',''], - 'xdm' => ['^xdm',0,'0','XDM',0,1,0,'',''], - 'xdmctl' => ['^xdm',0,'0','XDM',0,1,0,'',''],# opensuse/redhat may use this to start real dm - 'xenodm' => ['^xenodm',0,'0','xenodm',0,1,0,'',''], - 'xlogin' => ['^xlogin',0,'-V','xlogin',0,1,0,'',''], # unverified, probably clogin - ## Shells - not checked: ion, eshell ## - ## See ShellData::shell_test() for unhandled but known shells - 'ash' => ['',3,'pkg','ash',1,0,0,'',''], # special; dash precursor - 'bash' => ['^GNU[[:space:]]bash',4,'--version','Bash',1,1,0,'',''], - 'busybox' => ['^busybox',0,'0','BusyBox',1,0,0,'',''], # unverified, hush/ash likely - 'cicada' => ['^\s*version',2,'cmd','cicada',1,1,0,'',''], # special - 'csh' => ['^tcsh',2,'--version','csh',1,1,0,'',''], # mapped to tcsh often - 'dash' => ['',3,'pkg','DASH',1,0,0,'',''], # no version, pkg query - 'elvish' => ['^\S',1,'--version','Elvish',1,0,0,'',''], - 'fish' => ['^fish',3,'--version','fish',1,0,0,'',''], - 'fizsh' => ['^fizsh',3,'--version','FIZSH',1,0,0,'',''], - # ksh/lksh/loksh/mksh/posh//pdksh need to print their own $VERSION info - 'ksh' => ['^\S',1,'cmd','ksh',1,0,0,'^(Version|.*KSH)\s*',''], # special - 'ksh93' => ['^\S',1,'cmd','ksh93',1,0,0,'^(Version|.*KSH)\s*',''], # special - 'lksh' => ['^\S',1,'cmd','lksh',1,0,0,'^.*KSH\s*',''], # special - 'loksh' => ['^\S',1,'cmd','loksh',1,0,0,'^.*KSH\s*',''], # special - 'mksh' => ['^\S',1,'cmd','mksh',1,0,0,'^.*KSH\s*',''], # special - 'nash' => ['^nash',0,'0','Nash',1,0,0,'',''], # unverified; rc based [no version] - 'oh' => ['^oh',0,'0','Oh',1,0,0,'',''], # no version yet - 'oil' => ['^Oil',3,'--version','Oil',1,1,0,'',''], # could use cmd $OIL_SHELL - 'osh' => ['^osh',3,'--version','OSH',1,1,0,'',''], # precursor of oil - 'pdksh' => ['^\S',1,'cmd','pdksh',1,0,0,'^.*KSH\s*',''], # special, in ksh family - 'posh' => ['^\S',1,'cmd','posh',1,0,0,'',''], # special, in ksh family - 'tcsh' => ['^tcsh',2,'--version','tcsh',1,1,0,'',''], # enhanced csh - 'xonsh' => ['^xonsh',1,'--version','xonsh',1,0,0,'^xonsh[\/-]',''], - 'yash' => ['^Y',5,'--version','yash',1,0,0,'',''], - 'zsh' => ['^zsh',2,'--version','Zsh',1,0,0,'',''], - ## Tools ## - 'clang' => ['clang',3,'--version','Clang',1,0,0,'',''], - 'gcc' => ['^gcc',3,'--version','GCC',1,0,0,'',''], - 'gcc-apple' => ['Apple[[:space:]]LLVM',2,'--version','LLVM',1,0,0,'',''], - 'sudo' => ['^Sudo',3,'-V','Sudo',1,1,0,'',''], # sudo pre 1.7 does not have --version - ); -} - -# returns array of: -# 0: match string; 1: search number; 2: version string [alt: file]; -# 3: Print name; 4: console 0/1; -# 5: 0/1 exit version loop at 1 [alt: if version=file replace value with \s]; -# 6: 0/1 write to stderr [alt: if version=file, path for file]; -# 7: replace regex for further cleanup; 8: extra data -# note: setting index 1 or 2 to 0 will trip flags to not do version -# args: 0: program lower case name -sub program_values { - my $app = $_[0]; - my @program_data; - set_program_values() if !%program_values; - if (defined $program_values{$app}){ - @program_data = @{$program_values{$app}}; - } - # my $debug = Dumper \@program_data; - log_data('dump',"Program Data",\@program_data) if $b_log; - return @program_data; -} - -# args: 0: desktop/app command for --version; 1: search string; -# 2: space print number; 3: [optional] version arg: -v, version, etc; -# 4: [optional] exit first find 0/1; 5: [optional] 0/1 stderr output; -# 6: replace regex; 7: extra data -sub program_version { - eval $start if $b_log; - my ($app,$search,$num,$version,$exit,$stderr,$replace,$extra) = @_; - my ($b_no_space,$cmd,$line,$output); - my $version_nu = ''; - my $count = 0; - my $app_name = $app; - $app_name =~ s%^.*/%%; - # print "app: $app :: appname: $app_name\n"; - $exit ||= 100; # basically don't exit ever - $version ||= '--version'; - # adjust to array index, not human readable - $num-- if (defined $num && $num > 0); - # konvi in particular doesn't like using $ENV{'PATH'} as set, so we need - # to always assign the full path if it hasn't already been done - if ($version ne 'file' && $app !~ /^\//){ - if (my $program = check_program($app)){ - $app = $program; - } - else { - log_data('data',"$app not found in path.") if $b_log; - return 0; - } - } - if ($version eq 'file'){ - return 0 unless $extra && -r $extra; - my @data = reader($extra,'strip'); - @data = map {s/$stderr/ /;$_} @data if $stderr; # $stderr is the splitter - $output = join("\n", @data); - $cmd = ''; - } - # These will mostly be shells that require running the shell command -c to get info data - elsif ($version eq 'cmd'){ - ($cmd,$b_no_space) = program_version_cmd($app,$app_name,$extra); - return 0 if !$cmd; - } - # slow: use pkg manager to get version, avoid unless you really want version - elsif ($version eq 'pkg'){ - ($cmd,$search) = program_version_pkg($app_name); - return 0 if !$cmd; - } - # note, some wm/apps send version info to stderr instead of stdout - elsif ($stderr){ - $cmd = "$app $version 2>&1"; - } - else { - $cmd = "$app $version 2>/dev/null"; - } - log_data('data',"version: $version num: $num search: $search command: $cmd") if $b_log; - # special case, in rare instances version comes from file - if ($version ne 'file'){ - $output = qx($cmd); - log_data('data',"output: $output") if $b_log; - } - # print "cmd: $cmd\noutput:\n$output\n"; - # sample: dwm-5.8.2, ©.. etc, why no space? who knows. Also get rid of v in number string - # xfce, and other, output has , in it, so dump all commas and parentheses - if ($output){ - open(my $ch, '<', \$output) or error_handler('open-data',"$cmd", "$!"); - while (<$ch>){ - #chomp; - last if $count > $exit; - if ($_ =~ /$search/i){ - $_ = trimmer($_); - # print "loop: $_ :: num: $num\n"; - $_ =~ s/$replace//i if $replace; - $_ =~ s/\s/_/g if $b_no_space; # needed for some items with version > 1 word - my @data = split(/\s+/, $_); - $version_nu = $data[$num]; - last if ! defined $version_nu; - # some distros add their distro name before the version data, which - # breaks version detection. A quick fix attempt is to just add 1 to $num - # to get the next value. - $version_nu = $data[$num+1] if $data[$num+1] && $version_nu =~ /version/i; - $version_nu =~ s/(\([^)]+\)|,|"|\||\(|\))//g if $version_nu; - # trim off leading v but only when followed by a number - $version_nu =~ s/^v([0-9])/$1/i if $version_nu; - # print "$version_nu\n"; - last; - } - $count++; - } - close $ch if $ch; - } - log_data('data',"Program version: $version_nu") if $b_log; - eval $end if $b_log; - return $version_nu; -} -# print program_version('bash', 'bash', 4) . "\n"; - -# returns ($cmdd, $b_no_space) -# ksh: Version JM 93t+ 2010-03-05 [OR] Version A 2020.0.0 -# mksh: @(#)MIRBSD KSH R56 2018/03/09; lksh/pdksh: @(#)LEGACY KSH R56 2018/03/09 -# loksh: @(#)PD KSH v5.2.14 99/07/13.2; posh: 0.13.2 -sub program_version_cmd { - eval $start if $b_log; - my ($app,$app_name,$extra) = @_; - my @data = ('',0); - if ($app_name eq 'cicada'){ - $data[0] = $app . ' -c "' . $extra . '" 2>/dev/null';} - elsif ($app_name =~ /^(|l|lo|m|pd)ksh(93)?$/){ - $data[0] = $app . ' -c \'printf %s "$KSH_VERSION"\' 2>/dev/null'; - $data[1] = 1;} - elsif ($app_name eq 'posh'){ - $data[0] = $app . ' -c \'printf %s "$POSH_VERSION"\' 2>/dev/null'} - # print "$data[0] :: $data[1]\n"; - eval $end if $b_log; - return @data; -} - -# returns $cmd, $search -sub program_version_pkg { - eval $start if $b_log; - my ($app) = @_; - my ($program,@data); - # note: version $num is 3 in dpkg-query/pacman/rpm, which is convenient - if ($program = check_program('dpkg-query')){ - $data[0] = "$program -W -f='\${Package}\tversion\t\${Version}\n' $app 2>/dev/null"; - $data[1] = "^$app\\b"; - } - elsif ($program = check_program('pacman')){ - $data[0] = "$program -Q --info $app 2>/dev/null"; - $data[1] = '^Version'; - } - elsif ($program = check_program('rpm')){ - $data[0] = "$program -qi --nodigest --nosignature $app 2>/dev/null"; - $data[1] = '^Version'; - } - # print "$data[0] :: $data[1]\n"; - eval $end if $b_log; - return @data; -} - # args: 0: full file path, returns array of file lines; # 1: optionsl, strip and clean data; # 2: optional: undef|arr|ref|index return specific index, if it exists, else undef @@ -6470,11 +5962,11 @@ sub get_client_name { sub get_client_version { eval $start if $b_log; - @app = main::program_values($client{'name'}); + @app = ProgramData::values($client{'name'}); my (@data,@working,$string); if (@app){ $string = ($client{'name'} =~ /^gribble|limnoria|supybot$/) ? 'supybot' : $client{'name'}; - $client{'version'} = main::program_version($string,$app[0],$app[1],$app[2],$app[4],$app[5],$app[6]); + $client{'version'} = ProgramData::version($string,$app[0],$app[1],$app[2],$app[4],$app[5],$app[6]); $client{'name-print'} = $app[3]; $client{'console-irc'} = $app[4]; } @@ -6545,7 +6037,7 @@ sub get_client_version { # (KSirc sucks anyway ;) foreach (@$cmdline){ if ($_ =~ /dsirc/){ - $client{'version'} = main::program_version('ksirc','KSirc:',2,'-v',0,0); + $client{'version'} = ProgramData::version('ksirc','KSirc:',2,'-v',0,0); $client{'name'} = 'ksirc'; $client{'name-print'} = 'KSirc'; } @@ -6618,8 +6110,8 @@ sub perl_python_client { # main::print_line("konvi: " . scalar grep { $_ =~ /konversation/ } @ps_cmd); if ($b_display && main::check_program('konversation') && (grep { $_ =~ /konversation/ } @ps_cmd)){ - @app = main::program_values('konversation'); - $client{'version'} = main::program_version('konversation',$app[0],$app[1],$app[2],$app[5],$app[6]); + @app = ProgramData::values('konversation'); + $client{'version'} = ProgramData::version('konversation',$app[0],$app[1],$app[2],$app[5],$app[6]); $client{'name'} = 'konversation'; $client{'name-print'} = $app[3]; $client{'console-irc'} = $app[4]; @@ -6630,8 +6122,8 @@ sub perl_python_client { (main::check_program('supybot') || main::check_program('gribble') || main::check_program('limnoria')) && (grep { $_ =~ /supybot/ } @ps_cmd)){ - @app = main::program_values('supybot'); - $client{'version'} = main::program_version('supybot',$app[0],$app[1],$app[2],$app[5],$app[6]); + @app = ProgramData::values('supybot'); + $client{'version'} = ProgramData::version('supybot',$app[0],$app[1],$app[2],$app[5],$app[6]); if ($client{'version'}){ if (grep { $_ =~ /gribble/ } @ps_cmd){ $client{'name'} = 'gribble'; @@ -6689,8 +6181,8 @@ sub check_modern_konvi { } # print "$pid $konvi\n"; if ($konvi){ - @app = main::program_values('konversation'); - $konvi_version = main::program_version($konvi,$app[0],$app[1],$app[2],$app[5],$app[6]); + @app = ProgramData::values('konversation'); + $konvi_version = ProgramData::version($konvi,$app[0],$app[1],$app[2],$app[5],$app[6]); $client{'console-irc'} = $app[4]; $client{'konvi'} = 3; $client{'name'} = 'konversation'; @@ -8010,7 +7502,7 @@ sub sound_data { $name = 'aRts'; $status = (grep {/artsd/} @ps_cmd) ? 'active': 'off'; $type = 'Server'; - $version = main::program_version($program,'^artsd',2,'-v',1); + $version = ProgramData::version($program,'^artsd',2,'-v',1); if ($extra > 1){ $test = [['artswrapper','daemon'],]; $helpers = sound_helpers($test); @@ -8028,7 +7520,7 @@ sub sound_data { $name = 'EsounD'; $status = (grep {/\besd\b/} @ps_cmd) ? 'active': 'off'; $type = 'Server'; - $version = main::program_version($program,'^Esound',3,'--version',1,1); + $version = ProgramData::version($program,'^Esound',3,'--version',1,1); # if ($extra > 1){ # $test = [['','daemon'],]; # $helpers = sound_helpers($test); @@ -8044,7 +7536,7 @@ sub sound_data { $name = 'JACK'; $status = jack_status(); $type = 'Server'; - $version = main::program_version($program,'^jackd',3,'--version',1); + $version = ProgramData::version($program,'^jackd',3,'--version',1); if ($extra > 1){ $test = [['a2jmidid','daemon'],['nsmd','daemon']]; $helpers = sound_helpers($test); @@ -8060,7 +7552,7 @@ sub sound_data { $name = 'NAS'; $status = (grep {/(^|\/)nasd/} @ps_cmd) ? 'active': 'off'; $type = 'Server'; - $version = main::program_version($program,'^Network Audio',5,'-V',1); + $version = ProgramData::version($program,'^Network Audio',5,'-V',1); if ($extra > 1){ $test = [['audiooss','oss-compat'],]; $helpers = sound_helpers($test); @@ -8076,7 +7568,7 @@ sub sound_data { $name = 'PipeWire'; $status = pipewire_status(); $type = 'Server'; - $version = main::program_version($program,'^Compiled with libpipe',4,'--version',1); + $version = ProgramData::version($program,'^Compiled with libpipe',4,'--version',1); if ($extra > 1){ # pipewire-alsa is a plugin, but is just some config files $test = [['pipewire-pulse','daemon'],['pipewire-media-session','daemon'], @@ -8102,7 +7594,7 @@ sub sound_data { $name = 'PulseAudio'; $status = pulse_status($program); $type = 'Server'; - $version = main::program_version($program,'^pulseaudio',2,'--version',1); + $version = ProgramData::version($program,'^pulseaudio',2,'--version',1); if ($extra > 1){ $test = [['pulseaudio-dlna','daemon'], ['pulseaudio-alsa','plugin','/etc/alsa/conf.d/*-pulseaudio-default.conf'], @@ -19176,11 +18668,11 @@ sub set_compositor_data { if (($extra > 1 || $graphics{'protocol'} eq 'wayland' || $b_android) && (!$show{'system'} || $compositor ne 'gnome-shell')){ $graphics{'compositors'} = [] if !$graphics{'compositors'}; - push(@{$graphics{'compositors'}},[main::program_data($compositor,$compositor)]); + push(@{$graphics{'compositors'}},[ProgramData::full($compositor,$compositor)]); } else { $graphics{'compositors'} = [] if !$graphics{'compositors'}; - push(@{$graphics{'compositors'}},[(main::program_values($compositor))[3]]); + push(@{$graphics{'compositors'}},[(ProgramData::values($compositor))[3]]); } } } @@ -28823,7 +28315,7 @@ sub version_bsd { if (ref $compiler ne 'ARRAY' || !@$compiler){ if (my $path = main::check_program('clang')){ $compiler->[0] = 'clang'; - $compiler->[1] =main::program_version($path,'clang',3,'--version'); + $compiler->[1] =ProgramData::version($path,'clang',3,'--version'); } } } @@ -29155,10 +28647,10 @@ sub get_kde_trinity_data { elsif ($desktop_session eq 'kde-plasma' || $xdg_desktop eq 'kde' || $kde_session_version){ if ($kde_session_version && $kde_session_version <= 4){ - @data = ($kded_name) ? main::program_values($kded_name) : (); + @data = ($kded_name) ? ProgramData::values($kded_name) : (); if (@data){ $desktop->[0] = $data[3]; - $desktop->[1] = main::program_version($kded,$data[0],$data[1],$data[2],$data[5],$data[6]); + $desktop->[1] = ProgramData::version($kded,$data[0],$data[1],$data[2],$data[5],$data[6]); # kded exists, so we can now get the qt data string as well if ($desktop->[1] && $kded){ @version_data = main::grabber("$kded --version 2>/dev/null"); @@ -29203,7 +28695,7 @@ sub get_kde_trinity_data { # note: this program has issues, it may appear to be in /usr/bin, but it # often fails to execute, so the below will have null output, but use as a # fall back test anyway. - ($desktop->[2],$desktop->[3]) = main::program_data('qmake'); + ($desktop->[2],$desktop->[3]) = ProgramData::full('qmake'); } $desktop->[2] ||= 'Qt'; } @@ -29257,7 +28749,7 @@ sub get_env_de_data { if ((($item->[0] && ($xdg_desktop eq $item->[1] || $desktop_session eq $item->[1])) || (!$item->[0] && ($xdg_desktop =~ /$item->[1]/ || $desktop_session =~ /$item->[1]/))) || ($item->[5] && @ps_gui && (grep {/$item->[5]/} @ps_gui))){ - ($desktop->[0],$desktop->[1]) = main::program_data($item->[2]); + ($desktop->[0],$desktop->[1]) = ProgramData::full($item->[2]); $b_gtk = $item->[3]; $b_qt = $item->[4]; last; @@ -29282,7 +28774,7 @@ sub get_env_xprop_gnome_based_data { if ($xdg_desktop eq 'cinnamon' || $gdmsession eq 'cinnamon' || ($b_xprop && (main::check_program('muffin') || main::check_program('cinnamon-session')) && main::awk(\@xprop,'_muffin'))){ - ($desktop->[0],$desktop->[1]) = main::program_data('cinnamon','cinnamon',0); + ($desktop->[0],$desktop->[1]) = ProgramData::full('cinnamon','cinnamon',0); $b_gtk = 1; $desktop->[0] ||= 'Cinnamon'; } @@ -29293,7 +28785,7 @@ sub get_env_xprop_gnome_based_data { my %versions = ('mate-about' => '','mate-session' => ''); foreach my $key (keys %versions){ if ($program = main::check_program($key)){ - @data = main::program_data($key,$program,0); + @data = ProgramData::full($key,$program,0); $desktop->[0] = $data[0]; $versions{$key} = $data[1]; } @@ -29306,10 +28798,10 @@ sub get_env_xprop_gnome_based_data { # See sub for logic and comments elsif (check_gnome()){ if (main::check_program('gnome-about')){ - ($desktop->[0],$desktop->[1]) = main::program_data('gnome-about'); + ($desktop->[0],$desktop->[1]) = ProgramData::full('gnome-about'); } elsif (main::check_program('gnome-shell')){ - ($desktop->[0],$desktop->[1]) = main::program_data('gnome','gnome-shell'); + ($desktop->[0],$desktop->[1]) = ProgramData::full('gnome','gnome-shell'); } $b_gtk = 1; $desktop->[0] ||= 'GNOME'; @@ -29377,13 +28869,13 @@ sub get_env_xfce_data { if ($xdg_desktop eq 'xfce' || $gdmsession eq 'xfce' || ($b_xprop && main::check_program('xfdesktop')) && main::awk(\@xprop,'^(xfdesktop|xfce)')){ - @data = main::program_values('xfdesktop'); + @data = ProgramData::values('xfdesktop'); $desktop->[0] = $data[3]; # xfdesktop --version out of x fails to get display, so no data @version_data = main::grabber('xfdesktop --version 2>/dev/null'); # out of x, this error goes to stderr, so it's an empty result $desktop->[1] = main::awk(\@version_data,$data[0],$data[1],'\s+'); - #$desktop->[1] = main::program_version('xfdesktop',$data[0],$data[1],$data[2],$data[5],$data[6]); + #$desktop->[1] = ProgramData::version('xfdesktop',$data[0],$data[1],$data[2],$data[5],$data[6]); if (!$desktop->[1]){ my $version = '4'; # just assume it's 4, we tried if (main::check_program('xfce4-panel')){ @@ -29397,19 +28889,19 @@ sub get_env_xfce_data { elsif (main::check_program('xfce-panel')){ $version = ''; } - @data = main::program_values("xfce${version}-panel"); + @data = ProgramData::values("xfce${version}-panel"); # print Data::Dumper::Dumper \@data; # this returns an error message to stdout in x, which breaks the version # xfce4-panel --version out of x fails to get display, so no data - $desktop->[1] = main::program_version("xfce${version}-panel",$data[0],$data[1],$data[2],$data[5],$data[6]); + $desktop->[1] = ProgramData::version("xfce${version}-panel",$data[0],$data[1],$data[2],$data[5],$data[6]); # out of x this kicks out an error: xfce4-panel: Cannot open display $desktop->[1] = '' if $desktop->[1] !~ /[0-9]\./; } $desktop->[0] ||= 'Xfce'; $desktop->[1] ||= ''; # xfce isn't going to be 4 forever if ($extra > 1){ - @data = main::program_values('xfdesktop-toolkit'); - #$desktop->[3] = main::program_version('xfdesktop',$data[0],$data[1],$data[2],$data[5],$data[6]); + @data = ProgramData::values('xfdesktop-toolkit'); + #$desktop->[3] = ProgramData::version('xfdesktop',$data[0],$data[1],$data[2],$data[5],$data[6]); $desktop->[3] = main::awk(\@version_data,$data[0],$data[1],'\s+'); $desktop->[2] = $data[3]; } @@ -29426,6 +28918,7 @@ sub get_env_xprop_misc_data { main::awk(\@xprop,'moksha'))){ # no -v or --version but version is in xprop -root # ENLIGHTENMENT_VERSION(STRING) = "Moksha 0.2.0.15989" + # note: toolkit: EFL $desktop->[0] = 'Moksha'; if ($b_xprop){ $desktop->[1] = main::awk(\@xprop,'(enlightenment|moksha)_version',2,'\s+=\s+'); @@ -29466,7 +28959,7 @@ sub get_env_xprop_misc_data { foreach my $item (@desktops){ if (main::check_program($item->[0]) && main::awk(\@xprop,$item->[1]) && (!$item->[4] || (@ps_gui && (grep {/$item->[4]/} @ps_gui)))){ - ($desktop->[0],$desktop->[1]) = main::program_data($item->[2]); + ($desktop->[0],$desktop->[1]) = ProgramData::full($item->[2]); last; } } @@ -29502,9 +28995,9 @@ sub get_ps_de_data { # print "1: $item->[1]\n"; if (grep {/^$item->[1]$/i} @ps_gui){ # print "2: $item->[1]\n"; - ($desktop->[0],$desktop->[1]) = main::program_data($item->[2],$item->[3]); + ($desktop->[0],$desktop->[1]) = ProgramData::full($item->[2],$item->[3]); if ($extra > 1 && $item->[0] eq 'xfdesktop'){ - ($desktop->[2],$desktop->[3]) = main::program_data('xfdesktop-toolkit',$item->[0],1); + ($desktop->[2],$desktop->[3]) = ProgramData::full('xfdesktop-toolkit',$item->[0],1); } last; } @@ -29529,9 +29022,9 @@ sub get_ps_de_data { # no need to use check program with short list of ps_gui if ($psg =~ /^($matches)$/){ my $item = $1; - ($desktop->[0],$desktop->[1]) = main::program_data($item); + ($desktop->[0],$desktop->[1]) = ProgramData::full($item); if ($extra > 1 && $item eq 'xfdesktop'){ - ($desktop->[2],$desktop->[3]) = main::program_data('xfdesktop-toolkit',$item,1); + ($desktop->[2],$desktop->[3]) = ProgramData::full('xfdesktop-toolkit',$item,1); } last; } @@ -29546,7 +29039,7 @@ sub get_ps_de_data { sub set_gtk_data { eval $start if $b_log; if (main::check_program('gtk-launch')){ - ($desktop->[2],$desktop->[3]) = main::program_data('gtk-launch'); + ($desktop->[2],$desktop->[3]) = ProgramData::full('gtk-launch'); } eval $end if $b_log; } @@ -29565,10 +29058,10 @@ sub set_qt_data { # alternate: qt4-default, qt4-qmake or qt5-default, qt5-qmake # often this exists, is executable, but actually is nothing, shows error if (!$desktop->[3] && main::check_program('qmake')){ - ($desktop->[2],$desktop->[3]) = main::program_data('qmake'); + ($desktop->[2],$desktop->[3]) = ProgramData::full('qmake'); } if (!$desktop->[3] && main::check_program('qtdiag')){ - ($desktop->[2],$desktop->[3]) = main::program_data('qtdiag'); + ($desktop->[2],$desktop->[3]) = ProgramData::full('qtdiag'); } if (!$desktop->[3] && ($program = main::check_program("kf$kde_version-config"))){ @version_data = main::grabber("$program --version 2>/dev/null"); @@ -29671,7 +29164,7 @@ sub get_wm_version { $temp = (split(/\s+/, $temp))[0]; $temp = lc($temp); $temp = 'wmaker' if $temp eq 'windowmaker'; - my @data = main::program_data($temp,$temp,3); + my @data = ProgramData::full($temp,$temp,3); return if !$data[0]; # print Data::Dumper::Dumper \@data; $desktop->[5] = $data[0] if $type eq 'manual'; @@ -30854,7 +30347,7 @@ sub get_display_manager { # greetd frontends: agreety dlm gtkgreet qtgreet tuigreet wlgreet # mlogin may be mlogind, not verified my @dms = qw(brzdm cdm clogin elogind emptty entranced - gdm gdm3 greetd kdm kdm3 kdmctl ldm lightdm lxdm ly mdm mlogin nodm + gdm gdm3 greetd kdm kdm3 kdmctl ldm lemurs lightdm lxdm ly mdm mlogin nodm pcdm qingy sddm seatd slim slimski tbsm tdm udm wdm xdm xdmctl xenodm xlogin); # these are the only one I know of so far that have version info. xlogin / # clogin do, -V, brzdm -v, but syntax not verified. @@ -30906,7 +30399,7 @@ sub get_display_manager { else {$path = $dm} # print "$path $extra\n"; @dm_info = (); - @data = program_data($dm,$path,3); + @data = ProgramData::full($dm,$path,3); $dm_info[0] = $data[0]; $dm_info[1] = $data[1]; if (scalar @dms > 1 && (my $temp = ServiceData::get('status',$dm))){ @@ -30914,19 +30407,22 @@ sub get_display_manager { } push(@$found,[@dm_info]); } - if (!@$found && @{$ps_data{'dm-active'}}){ - # ly does not have a run/pid file - if (grep {$_ eq 'ly'} @{$ps_data{'dm-active'}}){ - @data = program_data('ly','ly',3); - $dm_info[0] = $data[0]; - $dm_info[1] = $data[1]; - $found->[0] = [@dm_info]; - } - elsif (grep {/startx$/} @{$ps_data{'dm-active'}}){ - $found->[0] = ['startx']; - } - elsif (grep {$_ eq 'xinit'} @{$ps_data{'dm-active'}}){ - $found->[0] = ['xinit']; + if (!@$found){ + PsData::set_dm(); + if (@{$ps_data{'dm-active'}}){ + # ly does not have a run/pid file + if (grep {$_ eq 'ly'} @{$ps_data{'dm-active'}}){ + @data = ProgramData::full('ly','ly',3); + $dm_info[0] = $data[0]; + $dm_info[1] = $data[1]; + $found->[0] = [@dm_info]; + } + elsif (grep {/startx$/} @{$ps_data{'dm-active'}}){ + $found->[0] = ['startx']; + } + elsif (grep {$_ eq 'xinit'} @{$ps_data{'dm-active'}}){ + $found->[0] = ['xinit']; + } } } # might add this in, but the rate of new dm's makes it more likely it's an @@ -31183,7 +30679,7 @@ sub get_linux_distro { if (-d '/etc/guix' && $lc_issue =~ /^this is the gnu system\./){ $distro = 'Guix'; # They didn't use any standard paths or files for os data, sigh, use pm version - my $version = main::program_version('guix', '^guix', '4','--version',1); + my $version = ProgramData::version('guix', '^guix', '4','--version',1); $distro .= " $version" if $version; $b_skip_issue = 1; } @@ -32017,10 +31513,10 @@ sub get { if (($comm && $comm =~ /systemd/) || -e '/run/systemd/units'){ $init = 'systemd'; if ($program = main::check_program('systemd')){ - $init_version = main::program_version($program,'^systemd','2','--version',1); + $init_version = ProgramData::version($program,'^systemd','2','--version',1); } if (!$init_version && ($program = main::check_program('systemctl'))){ - $init_version = main::program_version($program,'^systemd','2','--version',1); + $init_version = ProgramData::version($program,'^systemd','2','--version',1); } if ($runlevel && $runlevel =~ /^\d$/){ my $target = ''; @@ -32042,7 +31538,7 @@ sub get { # epoch version == Epoch Init System 1.0.1 "Sage" elsif ($comm =~ /epoch/){ $init = 'Epoch'; - $init_version = main::program_version('epoch', '^Epoch', '4','version'); + $init_version = ProgramData::version('epoch', '^Epoch', '4','version'); } # if they fix dinit to show /proc/1/comm == dinit elsif ($comm =~ /^dinit/){ @@ -32051,7 +31547,7 @@ sub get { elsif ($comm =~ /finit/){ $init = 'finit'; if ($program = main::check_program('finit')){ - $init_version = main::program_version($program,'^Finit','2','-v',1); + $init_version = ProgramData::version($program,'^Finit','2','-v',1); } } # not verified @@ -32077,7 +31573,7 @@ sub get { } elsif ($comm =~ /shepherd/){ $init = 'Shepherd'; - $init_version = main::program_version('shepherd', '^shepherd', '4','--version',1); + $init_version = ProgramData::version('shepherd', '^shepherd', '4','--version',1); } # fallback for some inits that link to /sbin/init elsif ($comm eq 'init'){ @@ -32093,13 +31589,13 @@ sub get { if (!$init){ # openwrt/busybox /sbin/init hangs on --version command if (-e '/sbin/init' && $link && $link =~ /busybox/){ - $init_version = main::program_version('init', 'busybox', '2','--help',1,1); + $init_version = ProgramData::version('init', 'busybox', '2','--help',1,1); $init = 'BusyBox'; } # risky since we don't know which init it is. $comm == 'init' # output: /sbin/init --version: init (upstart 1.1); init (upstart 0.6.3) elsif (!%risc && !$link && main::globber('/{usr/lib,sbin,var/log}/upstart*') && - ($init_version = main::program_version('init', 'upstart', '3','--version'))){ + ($init_version = ProgramData::version('init', 'upstart', '3','--version'))){ $init = 'Upstart'; } # surely more positive way to detect active @@ -32148,7 +31644,7 @@ sub dinit_data { $init = 'dinit'; # Dinit version 0.15.1. if ($program = main::check_program('dinit')){ - $init_version = main::program_version($program,'^Dinit','3','--version',1); + $init_version = ProgramData::version($program,'^Dinit','3','--version',1); $init_version =~ s/\.$//; } eval $end if $b_log; @@ -32159,11 +31655,11 @@ sub openrc_data { my $version; # /sbin/openrc --version == openrc (OpenRC) 0.13 if ($program = main::check_program('openrc')){ - $version = main::program_version($program, '^openrc', '3','--version'); + $version = ProgramData::version($program, '^openrc', '3','--version'); } # /sbin/rc --version == rc (OpenRC) 0.11.8 (Gentoo Linux) elsif ($program = main::check_program('rc')){ - $version = main::program_version($program, '^rc', '3','--version'); + $version = ProgramData::version($program, '^rc', '3','--version'); } eval $end if $b_log; return ('OpenRC',$version); @@ -34417,6 +33913,530 @@ sub sys_data { } } +# ProgramData +# public subs: +# full() - returns (print name, version nu). +# values() - returns program values array +# version() - returns program version number +{ +package ProgramData; + +# returns array of: 0: program print name 1: program version +# args: 0: program values ID; 1: program version string; +# 2: $extra level. Note that StartClient runs BEFORE -x levels are set! +# Only use this function when you only need the name/version data returned +sub full { + eval $start if $b_log; + my ($values_id,$version_id,$level) = @_; + my (@full,$path); + $level = 0 if !$level; + # print "val_id: $values_id ver_id:$version_id lev:$level ex:$extra\n"; + $version_id = $values_id if !$version_id; + my @values = ProgramData::values($values_id); # values() is a Perl builtin. + if ($values[3]){ + $full[0] = $values[3]; + # programs that have no version method return 0 0 for index 1 and 2 + if ($extra >= $level && $values[1] && $values[2]){ + $full[1] = version($version_id,$values[0],$values[1],$values[2], + $values[5],$values[6],$values[7],$values[8]); + } + } + $full[0] ||= ''; + $full[1] ||= ''; + eval $end if $b_log; + return @full; +} + +# It's almost 1000 times slower to load these each time values() is called!! +# %program_values: key: desktop/app command for --version => [0: search string; +# 1: space print number; 2: [optional] version arg: -v, version, etc; +# 3: print name; 4: console 0/1; 5: [optional] exit first find 0/1; +# 6: [optional] 0/1 stderr output; 7: replace regex; 8: extra data] +sub set_values { + %program_values = ( + ## Clients ## + 'bitchx' => ['bitchx',2,'','BitchX',1,0,0,'',''],# special + 'finch' => ['finch',2,'-v','Finch',1,1,0,'',''], + 'gaim' => ['[0-9.]+',2,'-v','Gaim',0,1,0,'',''], + 'ircii' => ['[0-9.]+',3,'-v','ircII',1,1,0,'',''], + 'irssi' => ['irssi',2,'-v','Irssi',1,1,0,'',''], + 'irssi-text' => ['irssi',2,'-v','Irssi',1,1,0,'',''], + 'konversation' => ['konversation',2,'-v','Konversation',0,0,0,'',''], + 'kopete' => ['Kopete',2,'-v','Kopete',0,0,0,'',''], + 'kvirc' => ['[0-9.]+',2,'-v','KVIrc',0,0,1,'',''], # special + 'pidgin' => ['[0-9.]+',2,'-v','Pidgin',0,1,0,'',''], + 'quassel' => ['',1,'-v','Quassel [M]',0,0,0,'',''], # special + 'quasselclient' => ['',1,'-v','Quassel',0,0,0,'',''],# special + 'quasselcore' => ['',1,'-v','Quassel (core)',0,0,0,'',''],# special + 'gribble' => ['^Supybot',2,'--version','Gribble',1,0,0,'',''],# special + 'limnoria' => ['^Supybot',2,'--version','Limnoria',1,0,0,'',''],# special + 'supybot' => ['^Supybot',2,'--version','Supybot',1,0,0,'',''],# special + 'weechat' => ['[0-9.]+',1,'-v','WeeChat',1,0,0,'',''], + 'weechat-curses' => ['[0-9.]+',1,'-v','WeeChat',1,0,0,'',''], + 'xchat-gnome' => ['[0-9.]+',2,'-v','X-Chat-Gnome',1,1,0,'',''], + 'xchat' => ['[0-9.]+',2,'-v','X-Chat',1,1,0,'',''], + ## Desktops / wm / compositors ## + '2bwm' => ['^2bwm',0,'0','2bWM',0,1,0,'',''], # unverified/based on mcwm + '3dwm' => ['^3dwm',0,'0','3Dwm',0,1,0,'',''], # unverified + '5dwm' => ['^5dwm',0,'0','5Dwm',0,1,0,'',''], # unverified + '9wm' => ['^9wm',3,'-version','9wm',0,1,0,'',''], + 'aewm' => ['^aewm',3,'--version','aewm',0,1,0,'',''], + 'aewm++' => ['^Version:',2,'-version','aewm++',0,1,0,'',''], + 'afterstep' => ['^afterstep',3,'--version','AfterStep',0,1,0,'',''], + 'amiwm' => ['^amiwm',0,'0','AmiWM',0,1,0,'',''], # no version + 'antiwm' => ['^antiwm',0,'0','AntiWM',0,1,0,'',''], # no version known + 'asc' => ['^asc',0,'0','asc',0,1,0,'',''], + 'awc' => ['^awc',0,'0','awc',0,1,0,'',''], # unverified + 'awesome' => ['^awesome',2,'--version','awesome',0,1,0,'',''], + 'beryl' => ['^beryl',0,'0','Beryl',0,1,0,'',''], # unverified; legacy + 'bismuth' => ['^bismuth',0,'0','Bismuth',0,1,0,'',''], # unverified + 'blackbox' => ['^Blackbox',2,'--version','Blackbox',0,1,0,'',''], + 'bspwm' => ['^\S',1,'-v','bspwm',0,1,0,'',''], + 'budgie-desktop' => ['^budgie-desktop',2,'--version','Budgie',0,1,0,'',''], + 'budgie-wm' => ['^budgie',0,'0','budgie-wm',0,1,0,'',''], + 'cage' => ['^cage',0,'0','Cage',0,1,0,'',''], # unverified + 'cagebreak' => ['^Cagebreak',3,'-v','Cagebreak',0,1,0,'',''], + 'calmwm' => ['^calmwm',0,'0','CalmWM',0,1,0,'',''], # unverified + 'cardboard' => ['^cardboard',0,'0','Cardboard',0,1,0,'',''], # unverified + 'catwm' => ['^catwm',0,'0','catwm',0,1,0,'',''], # unverified + 'cde' => ['^cde',0,'0','CDE',0,1,0,'',''], # unverified + 'chameleonwm' => ['^chameleon',0,'0','ChameleonWM',0,1,0,'',''], # unverified + 'cinnamon' => ['^cinnamon',2,'--version','Cinnamon',0,1,0,'',''], + 'clfswm' => ['^clsfwm',0,'0','clfswm',0,1,0,'',''], # no version + 'comfc' => ['^comfc',0,'0','comfc',0,1,0,'',''], # unverified + 'compiz' => ['^compiz',2,'--version','Compiz',0,1,0,'',''], + 'compton' => ['^\d',1,'--version','Compton',0,1,0,'',''], + 'cosmic-comp' => ['^cosmic-comp',0,'0','cosmic-comp',0,1,0,'',''], # unverified + 'ctwm' => ['^\S',1,'-version','ctwm',0,1,0,'',''], + 'cwm' => ['^cwm',0,'0','CWM',0,1,0,'',''], # no version + 'dawn' => ['^dawn',1,'-v','dawn',0,1,1,'^dawn-',''], # to stderr, not verified + 'dcompmgr' => ['^dcompmgr',0,'0','dcompmgr',0,1,0,'',''], # unverified + 'deepin' => ['^Version',2,'file','Deepin',0,100,'=','','/etc/deepin-version'], # special + 'deepin-metacity' => ['^metacity',2,'--version','Deepin-Metacity',0,1,0,'',''], + 'deepin-mutter' => ['^mutter',2,'--version','Deepin-Mutter',0,1,0,'',''], + 'deepin-wm' => ['^gala',0,'0','DeepinWM',0,1,0,'',''], # no version + 'dusk' => ['^dusk',1,'-v','dusk',0,1,1,'^dusk-',''], # to stderr, not verified + 'dwc' => ['^dwc',0,'0','dwc',0,1,0,'',''], # unverified + 'dwl' => ['^dwl',0,'0','dwl',0,1,0,'',''], # unverified + 'dwm' => ['^dwm',1,'-v','dwm',0,1,1,'^dwm-',''], + 'echinus' => ['^echinus',1,'-v','echinus',0,1,1,'',''], # echinus-0.4.9 (c)... + # only listed here for compositor values, version data comes from xprop + 'enlightenment' => ['^enlightenment',0,'0','enlightenment',0,1,0,'',''], # no version, yet? + 'epd-wm' => ['^epd-wm',0,'0','epd-wm',0,1,0,'',''], # unverified + 'evilwm' => ['evilwm',3,'-V','evilwm',0,1,0,'',''],# might use full path in match + 'feathers' => ['^feathers',0,'0','feathers',0,1,0,'',''], # unverified + 'fenestra' => ['^fenestra',0,'0','fenestra',0,1,0,'',''], # unverified + 'fireplace' => ['^fireplace',0,'0','fireplace',0,1,0,'',''], # unverified + 'fluxbox' => ['^fluxbox',2,'-v','Fluxbox',0,1,0,'',''], + 'flwm' => ['^flwm',0,'0','FLWM',0,0,1,'',''], # no version + # openbsd changed: version string: [FVWM[[main] Fvwm.. sigh, and outputs to stderr. Why? + 'fvwm' => ['^fvwm',2,'-version','FVWM',0,1,0,'',''], + 'fvwm1' => ['^Fvwm',3,'-version','FVWM1',0,1,1,'',''], + 'fvwm2' => ['^fvwm',2,'--version','FVWM2',0,1,0,'',''], + 'fvwm3' => ['^fvwm',2,'--version','FVWM3',0,1,0,'',''], + 'fvwm95' => ['^fvwm',2,'--version','FVWM95',0,1,1,'',''], + 'fvwm-crystal' => ['^fvwm',2,'--version','FVWM-Crystal',0,0,0,'',''], # for print name fvwm + 'gala' => ['^gala',0,'0','gala',0,1,0,'',''], # pantheon wm: super slow result, 2, '--version' works? + 'gamescope' => ['^gamescope',0,'0','Gamescope',0,1,0,'',''], # unverified + 'glass' => ['^glass',3,'-v','Glass',0,1,0,'',''], + 'gnome' => ['^gnome',3,'--version','GNOME',0,1,0,'',''], # no version, print name + 'gnome-about' => ['^gnome',3,'--version','GNOME',0,1,0,'',''], + 'gnome-shell' => ['^gnome',3,'--version','gnome-shell',0,1,0,'',''], + 'greenfield' => ['^greenfield',0,'0','Greenfield',0,1,0,'',''], # unverified + 'grefson' => ['^grefson',0,'0','Grefson',0,1,0,'',''], # unverified + 'hackedbox' => ['^hackedbox',2,'-version','HackedBox',0,1,0,'',''], # unverified, assume blackbox + # note, herbstluftwm when launched with full path returns full path in version string + 'herbstluftwm' => ['herbstluftwm',2,'--version','herbstluftwm',0,1,0,'',''], + 'hikari' => ['^hikari',0,'0','hikari',0,1,0,'',''], # unverified + 'hopalong' => ['^hopalong',0,'0','Hopalong',0,1,0,'',''], # unverified + 'hyprctl' => ['^Tag:',2,'version','Hyprland',0,1,0,'',''], # method to get hyprland version + 'hyprland' => ['^hyprland',0,'0','Hyprland',0,1,0,'',''], # uses hyprctl for version + 'i3' => ['^i3',3,'--version','i3',0,1,0,'',''], + 'icewm' => ['^icewm',2,'--version','IceWM',0,1,0,'',''], + 'inaban' => ['^inaban',0,'0','inaban',0,1,0,'',''], # unverified + 'instantwm' => ['^instantwm',1,'-v','instantWM',0,1,1,'^instantwm-?(instantos-?)?',''], + 'ion3' => ['^ion3',0,'--version','Ion3',0,1,0,'',''], # unverified; also shell called ion + 'japokwm' => ['^japokwm',0,'0','japokwm',0,1,0,'',''], # unverified + 'jbwm' => ['jbwm',3,'-v','JBWM',0,1,0,'',''], # might use full path in match + 'jwm' => ['^jwm',2,'--version','JWM',0,1,0,'',''], + 'kded' => ['^KDE( Development Platform)?:',2,'--version','KDE',0,1,0,'\sDevelopment Platform',''], + 'kded1' => ['^KDE( Development Platform)?:',2,'--version','KDE',0,1,0,'\sDevelopment Platform',''], + 'kded2' => ['^KDE( Development Platform)?:',2,'--version','KDE',0,1,0,'\sDevelopment Platform',''], + 'kded3' => ['^KDE( Development Platform)?:',2,'--version','KDE',0,1,0,'\sDevelopment Platform',''], + 'kded4' => ['^KDE( Development Platform)?:',2,'--version','KDE',0,1,0,'\sDevelopment Platform',''], + 'kiwmi' => ['^kwimi',0,'0','kiwmi',0,1,0,'',''], # unverified + 'ksmcon' => ['^ksmcon',0,'0','ksmcon',0,1,0,'',''],# no version + 'kwin' => ['^kwin',0,'0','kwin',0,1,0,'',''],# no version + 'kwin_wayland' => ['^kwin_wayland',0,'0','kwin_wayland',0,1,0,'',''],# no version + 'kwin_x11' => ['^kwin_x11',0,'0','kwin_x11',0,1,0,'',''],# no version + 'kwinft' => ['^kwinft',0,'0','KWinFT',0,1,0,'',''], # unverified + 'labwc' => ['^labwc',0,'0','LabWC',0,1,0,'',''], # unverified + 'laikawm' => ['^laikawm',0,'0','LaikaWM',0,1,0,'',''], # unverified + 'larswm' => ['^larswm',2,'-v','larswm',0,1,1,'',''], + 'leftwm' => ['^leftwm',0,'0','LeftWM',0,1,0,'',''],# no version, in CHANGELOG + 'liri' => ['^liri',0,'0','liri',0,1,0,'',''], + 'lipstick' => ['^lipstick',0,'0','Lipstick',0,1,0,'',''], # unverified + 'liri' => ['^liri',0,'0','liri',0,1,0,'',''], # unverified + 'lumina-desktop' => ['^\S',1,'--version','Lumina',0,1,1,'',''], + 'lwm' => ['^lwm',0,'0','lwm',0,1,0,'',''], # no version + 'lxpanel' => ['^lxpanel',2,'--version','LXDE',0,1,0,'',''], + # command: lxqt-panel + 'lxqt-panel' => ['^lxqt-panel',2,'--version','LXQt',0,1,0,'',''], + 'lxqt-variant' => ['^lxqt-panel',0,'0','LXQt-Variant',0,1,0,'',''], + 'lxsession' => ['^lxsession',0,'0','lxsession',0,1,0,'',''], + 'mahogany' => ['^mahogany',0,'0','Mahogany',0,1,0,'',''], # unverified + 'manokwari' => ['^manokwari',0,'0','Manokwari',0,1,0,'',''], + 'marina' => ['^marina',0,'0','Marina',0,1,0,'',''], # unverified + 'marco' => ['^marco',2,'--version','marco',0,1,0,'',''], + 'matchbox' => ['^matchbox',0,'0','Matchbox',0,1,0,'',''], + 'matchbox-window-manager' => ['^matchbox',2,'--help','Matchbox',0,0,0,'',''], + 'mate-about' => ['^MATE[[:space:]]DESKTOP',-1,'--version','MATE',0,1,0,'',''], + # note, mate-session when launched with full path returns full path in version string + 'mate-session' => ['mate-session',-1,'--version','MATE',0,1,0,'',''], + 'maynard' => ['^maynard',0,'0','maynard',0,1,0,'',''], # unverified + 'maze' => ['^maze',0,'0','Maze',0,1,0,'',''], # unverified + 'mcwm' => ['^mcwm',0,'0','mcwm',0,1,0,'',''], # unverified/see 2bwm + 'metacity' => ['^metacity',2,'--version','Metacity',0,1,0,'',''], + 'metisse' => ['^metisse',0,'0','metisse',0,1,0,'',''], + 'mini' => ['^Mini',5,'--version','Mini',0,1,0,'',''], + 'mir' => ['^mir',0,'0','mir',0,1,0,'',''],# unverified + 'moblin' => ['^moblin',0,'0','moblin',0,1,0,'',''],# unverified + 'monsterwm' => ['^monsterwm',0,'0','monsterwm',0,1,0,'',''],# unverified + 'motorcar' => ['^motorcar',0,'0','motorcar',0,1,0,'',''],# unverified + 'muffin' => ['^muffin',2,'--version','Muffin',0,1,0,'',''], + 'musca' => ['^musca',0,'-v','Musca',0,1,0,'',''], # unverified + 'mutter' => ['^mutter',2,'--version','Mutter',0,1,0,'',''], + 'mwm' => ['^mwm',0,'0','MWM',0,1,0,'',''],# no version + 'nawm' => ['^nawm',0,'0','nawm',0,1,0,'',''],# unverified + 'newm' => ['^newm',0,'0','newm',0,1,0,'',''], # unverified + 'notion' => ['^.',1,'--version','Notion',0,1,0,'',''], + 'nscde' => ['^nscde',0,'0','NsCDE',0,1,0,'',''], # unverified + 'nucleus' => ['^nucleus',0,'0','Nucleus',0,1,0,'',''], # unverified + 'openbox' => ['^openbox',2,'--version','Openbox',0,1,0,'',''], + 'orbital' => ['^orbital',0,'0','Orbital',0,1,0,'',''],# unverified + 'orbment' => ['^orbment',0,'0','orbment',0,1,0,'',''], # unverified + 'pantheon' => ['^pantheon',0,'0','Pantheon',0,1,0,'',''],# no version + 'papyros' => ['^papyros',0,'0','papyros',0,1,0,'',''],# no version + 'pekwm' => ['^pekwm',3,'--version','PekWM',0,1,0,'',''], + 'penrose' => ['^penrose',0,'0','Penrose',0,1,0,'',''],# no version? + 'perceptia' => ['^perceptia',0,'0','perceptia',0,1,0,'',''], + 'phoc' => ['^phoc',0,'0','phoc',0,1,0,'',''], # unverified + 'picom' => ['^\S',1,'--version','Picom',0,1,0,'^v',''], + 'plasmashell' => ['^plasmashell',2,'--version','KDE Plasma',0,1,0,'',''], + 'polonium' => ['^polonium',0,'0','polonium',0,1,0,'',''], # unverified + 'pywm' => ['^pywm',0,'0','pywm',0,1,0,'',''], # unverified + 'qtile' => ['^',1,'--version','Qtile',0,1,0,'',''], + 'qvwm' => ['^qvwm',0,'0','qvwm',0,1,0,'',''], # unverified + 'razor-session' => ['^razor',0,'0','Razor-Qt',0,1,0,'',''], + 'ratpoison' => ['^ratpoison',2,'--version','Ratpoison',0,1,0,'',''], + 'river' => ['^river',0,'0','River',0,1,0,'',''], # unverified + 'rootston' => ['^rootston',0,'0','rootston',0,1,0,'',''], # unverified, wlroot ref + 'rustland' => ['^rustland',0,'0','rustland',0,1,0,'',''], # unverified + 'sawfish' => ['^sawfish',3,'--version','Sawfish',0,1,0,'',''], + 'scrotwm' => ['^scrotwm.*welcome.*',5,'-v','scrotwm',0,1,1,'',''], + 'simulavr' => ['simulavr^',0,'0','SimulaVR',0,1,0,'',''], # unverified + 'skylight' => ['^skylight',0,'0','Skylight',0,1,0,'',''], # unverified + 'smithay' => ['^smithay',0,'0','Smithay',0,1,0,'',''], # unverified + 'sommelier' => ['^sommelier',0,'0','sommelier',0,1,0,'',''], # unverified + 'snapwm' => ['^snapwm',0,'0','snapwm',0,1,0,'',''], # unverified + 'spectrwm' => ['^spectrwm.*welcome.*wm',5,'-v','spectrwm',0,1,1,'',''], + # out of stump, 2 --version, but in tries to start new wm instance endless hang + 'stumpwm' => ['^SBCL',0,'--version','StumpWM',0,1,0,'',''], # hangs when run in wm + 'surfaceflinger' => ['surfaceflinger^',0,'0','SurfaceFlinger',0,1,0,'',''], # Android, unverified + 'sway' => ['^sway',3,'-v','Sway',0,1,0,'',''], + 'swayfx' => ['^swayfx',0,'0','SwayFX',0,1,0,'',''], # probably same as sway, unverified + 'swayfx' => ['^sway',3,'-v','SwayFX',0,1,0,'',''], # not sure if safe + 'swc' => ['^swc',0,'0','swc',0,1,0,'',''], # unverified + 'swvkc' => ['^swvkc',0,'0','swvkc',0,1,0,'',''], # unverified + 'tabby' => ['^tabby',0,'0','Tabby',0,1,0,'',''], # unverified + 'taiwins' => ['^taiwins',0,'0','taiwins',0,1,0,'',''], # unverified + 'tinybox' => ['^tinybox',0,'0','tinybox',0,1,0,'',''], # unverified + 'tinywl' => ['^tinywl',0,'0','TinyWL',0,1,0,'',''], # unverified + 'tinywm' => ['^tinywm',0,'0','TinyWM',0,1,0,'',''], # no version + 'trinkster' => ['^trinkster',0,'0','Trinkster',0,1,0,'',''], # unverified + 'tvtwm' => ['^tvtwm',0,'0','tvtwm',0,1,0,'',''], # unverified + 'twin' => ['^Twin:',2,'--version','Twin',0,0,0,'',''], + 'twm' => ['^twm',0,'0','TWM',0,1,0,'',''], # no version + 'ukui' => ['^ukui-session',2,'--version','UKUI',0,1,0,'',''], + 'ukwm' => ['^ukwm',2,'--version','ukwm',0,1,0,'',''], + 'unagi' => ['^\S',1,'--version','unagi',0,1,0,'',''], + 'unity' => ['^unity',2,'--version','Unity',0,1,0,'',''], + 'unity-system-compositor' => ['^unity-system-compositor',2,'--version', + 'unity-system-compositor (mir)',0,0,0,'',''], + 'uwm' => ['^uwm',0,'0','UWM',0,1,0,'',''], # unverified + 'velox' => ['^velox',0,'0','Velox',0,1,0,'',''], # unverified + 'vimway' => ['^vimway',0,'0','vimway',0,1,0,'',''], # unverified + 'vivarium' => ['^vivarium',0,'0','Vivarium',0,1,0,'',''], # unverified + 'wavy' => ['^wavy',0,'0','wavy',0,1,0,'',''], # unverified + 'waybox' => ['^way',0,'0','waybox',0,1,0,'',''], # unverified + 'waycooler' => ['^way',3,'--version','way-cooler',0,1,0,'',''], + 'way-cooler' => ['^way',3,'--version','way-cooler',0,1,0,'',''], + 'wayfire' => ['^\d',1,'--version','wayfire',0,1,0,'',''], # -version/--version + 'wayhouse' => ['^wayhouse',0,'0','wayhouse',0,1,0,'',''], # unverified + 'waymonad' => ['^waymonad',0,'0','waymonad',0,1,0,'',''], # unverified + 'westeros' => ['^westeros',0,'0','westeros',0,1,0,'',''], # unverified + 'westford' => ['^westford',0,'0','westford',0,1,0,'',''], # unverified + 'weston' => ['^weston',0,'0','Weston',0,1,0,'',''], # unverified + 'windowlab' => ['^windowlab',2,'-about','WindowLab',0,1,0,'',''], + 'wingo' => ['^wingo',0,'0','Wingo',0,1,0,'',''], # unverified + 'wio' => ['^wio',0,'0','Wio',0,1,0,'',''], # unverified + 'wio' => ['^wio\+',0,'0','wio+',0,1,0,'',''], # unverified + 'wm2' => ['^wm2',0,'0','wm2',0,1,0,'',''], # no version + 'wmaker' => ['^Window\s*Maker',-1,'--version','WindowMaker',0,1,0,'',''], + 'wmfs' => ['^wmfs',0,'0','WMFS',0,1,0,'',''], # unverified + 'wmfs2' => ['^wmfs',0,'0','WMFS',0,1,0,'',''], # unverified + 'wmii' => ['^wmii',1,'-v','wmii',0,1,0,'^wmii[234]?-',''], # wmii is wmii3 + 'wmii2' => ['^wmii2',1,'--version','wmii2',0,1,0,'^wmii[234]?-',''], + 'wmx' => ['^wmx',0,'0','wmx',0,1,0,'',''], # no version + 'wxrc' => ['^wx',0,'0','',0,1,0,'WXRC',''], # unverified + 'wxrd' => ['^wx',0,'0','',0,1,0,'WXRD',''], # unverified + 'xcompmgr' => ['^xcompmgr',0,'0','xcompmgr',0,1,0,'',''], # no version + 'xfce-panel' => ['^xfce-panel',2,'--version','Xfce',0,1,0,'',''], + 'xfce4-panel' => ['^xfce4-panel',2,'--version','Xfce',0,1,0,'',''], + 'xfce5-panel' => ['^xfce5-panel',2,'--version','Xfce',0,1,0,'',''], + 'xfdesktop' => ['xfdesktop[[:space:]]version',5,'--version','Xfce',0,1,0,'',''], + # command: xfdesktop + 'xfdesktop-toolkit' => ['Built[[:space:]]with[[:space:]]GTK',4,'--version','Gtk',0,1,0,'',''], + # ' This is xfwm4 version 4.16.1 (revision 5f61a84ad) for Xfce 4.16' + 'xfwm' => ['xfwm[3-8]? version',5,'--version','xfwm',0,1,0,'^^\s+',''],# unverified + 'xfwm4' => ['xfwm4? version',5,'--version','xfwm',0,1,0,'^^\s+',''], + 'xfwm5' => ['xfwm5? version',5,'--version','xfwm',0,1,0,'^^\s+',''], # unverified + 'xmonad' => ['^xmonad',2,'--version','XMonad',0,1,0,'',''], + 'xuake' => ['^xuake',0,'0','xuake',0,1,0,'',''], # unverified + 'yeahwm' => ['^yeahwm',0,'--version','YeahWM',0,1,0,'',''], # unverified + ## Toolkits ## + 'gtk-launch' => ['^\S',1,'--version','GTK',0,1,0,'',''], + 'qmake' => ['^^Using Qt version',4,'--version','Qt',0,0,0,'',''], + 'qtdiag' => ['^qt',2,'--version','Qt',0,1,0,'',''], + ## Display Managers (dm) ## + 'brzdm' => ['^brzdm version',3,'-v','brzdm',0,1,0,'',''], # unverified, slim fork + 'cdm' => ['^cdm',0,'0','CDM',0,1,0,'',''], + # might be xlogin, unknown output for -V + 'clogin' => ['^clogin',0,'-V','clogin',0,1,0,'',''], # unverified, maybe xlogin + 'elogind' => ['^elogind',0,'0','elogind',0,1,0,'',''], + 'emptty' => ['^emptty',0,'0','EMPTTY',0,1,0,'',''], # unverified + 'entrance' => ['^entrance',0,'0','Entrance',0,1,0,'',''], + 'gdm' => ['^gdm',2,'--version','GDM',0,1,0,'',''], + 'gdm3' => ['^gdm',2,'--version','GDM3',0,1,0,'',''], + 'greetd' => ['^greetd',0,'0','greetd',0,1,0,'',''], # no version + 'kdm' => ['^kdm',0,'0','KDM',0,1,0,'',''], + 'kdm3' => ['^kdm',0,'0','KDM',0,1,0,'',''], + 'kdmctl' => ['^kdm',0,'0','KDM',0,1,0,'',''], + 'ldm' => ['^ldm',0,'0','LDM',0,1,0,'',''], + 'lemurs' => ['^lemurs',0,'0','lemurs',0,1,0,'',''], # unverified + 'lightdm' => ['^lightdm',2,'--version','LightDM',0,1,1,'',''], + 'lxdm' => ['^lxdm',0,'0','LXDM',0,1,0,'',''], + 'ly' => ['^ly',3,'--version','Ly',0,1,0,'',''], + 'mdm' => ['^mdm',0,'0','MDM',0,1,0,'',''], + 'mlogin' => ['^mlogin',0,'0','mlogin',0,1,0,'',''], # unverified + 'nodm' => ['^nodm',0,'0','nodm',0,1,0,'',''], + 'pcdm' => ['^pcdm',0,'0','PCDM',0,1,0,'',''], + 'qingy' => ['^qingy',0,'0','qingy',0,1,0,'',''], # unverified + 'seatd' => ['^seatd',3,'-v','seatd',0,1,0,'',''], + 'sddm' => ['^sddm',0,'0','SDDM',0,1,0,'',''], + 'slim' => ['slim version',3,'-v','SLiM',0,1,0,'',''], + 'slimski' => ['slimski version',3,'-v','slimski',0,1,0,'',''], # slim fork + 'tbsm' => ['^tbsm',0,'0','tbsm',0,1,0,'',''], # unverified + 'tdm' => ['^tdm',0,'0','TDM',0,1,0,'',''], + 'udm' => ['^udm',0,'0','udm',0,1,0,'',''], + 'wdm' => ['^wdm',0,'0','WINGs DM',0,1,0,'',''], + 'xdm' => ['^xdm',0,'0','XDM',0,1,0,'',''], + 'xdmctl' => ['^xdm',0,'0','XDM',0,1,0,'',''],# opensuse/redhat may use this to start real dm + 'xenodm' => ['^xenodm',0,'0','xenodm',0,1,0,'',''], + 'xlogin' => ['^xlogin',0,'-V','xlogin',0,1,0,'',''], # unverified, probably clogin + ## Shells - not checked: ion, eshell ## + ## See ShellData::shell_test() for unhandled but known shells + 'ash' => ['',3,'pkg','ash',1,0,0,'',''], # special; dash precursor + 'bash' => ['^GNU[[:space:]]bash',4,'--version','Bash',1,1,0,'',''], + 'busybox' => ['^busybox',0,'0','BusyBox',1,0,0,'',''], # unverified, hush/ash likely + 'cicada' => ['^\s*version',2,'cmd','cicada',1,1,0,'',''], # special + 'csh' => ['^tcsh',2,'--version','csh',1,1,0,'',''], # mapped to tcsh often + 'dash' => ['',3,'pkg','DASH',1,0,0,'',''], # no version, pkg query + 'elvish' => ['^\S',1,'--version','Elvish',1,0,0,'',''], + 'fish' => ['^fish',3,'--version','fish',1,0,0,'',''], + 'fizsh' => ['^fizsh',3,'--version','FIZSH',1,0,0,'',''], + # ksh/lksh/loksh/mksh/posh//pdksh need to print their own $VERSION info + 'ksh' => ['^\S',1,'cmd','ksh',1,0,0,'^(Version|.*KSH)\s*',''], # special + 'ksh93' => ['^\S',1,'cmd','ksh93',1,0,0,'^(Version|.*KSH)\s*',''], # special + 'lksh' => ['^\S',1,'cmd','lksh',1,0,0,'^.*KSH\s*',''], # special + 'loksh' => ['^\S',1,'cmd','loksh',1,0,0,'^.*KSH\s*',''], # special + 'mksh' => ['^\S',1,'cmd','mksh',1,0,0,'^.*KSH\s*',''], # special + 'nash' => ['^nash',0,'0','Nash',1,0,0,'',''], # unverified; rc based [no version] + 'oh' => ['^oh',0,'0','Oh',1,0,0,'',''], # no version yet + 'oil' => ['^Oil',3,'--version','Oil',1,1,0,'',''], # could use cmd $OIL_SHELL + 'osh' => ['^osh',3,'--version','OSH',1,1,0,'',''], # precursor of oil + 'pdksh' => ['^\S',1,'cmd','pdksh',1,0,0,'^.*KSH\s*',''], # special, in ksh family + 'posh' => ['^\S',1,'cmd','posh',1,0,0,'',''], # special, in ksh family + 'tcsh' => ['^tcsh',2,'--version','tcsh',1,1,0,'',''], # enhanced csh + 'xonsh' => ['^xonsh',1,'--version','xonsh',1,0,0,'^xonsh[\/-]',''], + 'yash' => ['^Y',5,'--version','yash',1,0,0,'',''], + 'zsh' => ['^zsh',2,'--version','Zsh',1,0,0,'',''], + ## Tools ## + 'clang' => ['clang',3,'--version','Clang',1,0,0,'',''], + 'gcc' => ['^gcc',3,'--version','GCC',1,0,0,'',''], + 'gcc-apple' => ['Apple[[:space:]]LLVM',2,'--version','LLVM',1,0,0,'',''], + 'sudo' => ['^Sudo',3,'-V','Sudo',1,1,0,'',''], # sudo pre 1.7 does not have --version + ); +} + +# returns array of: +# 0: match string; 1: search word number; 2: version string [alt: file]; +# 3: Print name; 4: console 0/1; +# 5: 0/1 exit version loop at 1 [alt: if version=file replace value with \s]; +# 6: 0/1 write to stderr [alt: if version=file, path for file]; +# 7: replace regex for further cleanup; 8: extra data +# note: setting index 1 or 2 to 0 will trip flags to not do version +# args: 0: program lower case name +sub values { + my $app = $_[0]; + my @values; + ProgramData::set_values() if !%program_values; + if (defined $program_values{$app}){ + @values = @{$program_values{$app}}; + } + # my $debug = Dumper \@values; + main::log_data('dump','@values',\@values) if $b_log; + return @values; +} + +# args: 0: desktop/app command for --version; 1: search string; +# 2: space print number; 3: [optional] version arg: -v, version, etc; +# 4: [optional] exit first find 0/1; 5: [optional] 0/1 stderr output; +# 6: replace regex; 7: extra data +sub version { + eval $start if $b_log; + my ($app,$search,$num,$version,$exit,$stderr,$replace,$extra) = @_; + my ($b_no_space,$cmd,$line,$output); + my $version_nu = ''; + my $count = 0; + my $app_name = $app; + $app_name =~ s%^.*/%%; + # print "app: $app :: appname: $app_name\n"; + $exit ||= 100; # basically don't exit ever + $version ||= '--version'; + # adjust to array index, not human readable + $num-- if (defined $num && $num > 0); + # konvi in particular doesn't like using $ENV{'PATH'} as set, so we need + # to always assign the full path if it hasn't already been done + if ($version ne 'file' && $app !~ /^\//){ + if (my $program = main::check_program($app)){ + $app = $program; + } + else { + main::log_data('data',"$app not found in path.") if $b_log; + return 0; + } + } + if ($version eq 'file'){ + return 0 unless $extra && -r $extra; + my @data = main::reader($extra,'strip'); + @data = map {s/$stderr/ /;$_} @data if $stderr; # $stderr is the splitter + $output = join("\n", @data); + $cmd = ''; + } + # These will mostly be shells that require running the shell command -c to get info data + elsif ($version eq 'cmd'){ + ($cmd,$b_no_space) = version_cmd($app,$app_name,$extra); + return 0 if !$cmd; + } + # slow: use pkg manager to get version, avoid unless you really want version + elsif ($version eq 'pkg'){ + ($cmd,$search) = version_pkg($app_name); + return 0 if !$cmd; + } + # note, some wm/apps send version info to stderr instead of stdout + elsif ($stderr){ + $cmd = "$app $version 2>&1"; + } + else { + $cmd = "$app $version 2>/dev/null"; + } + main::log_data('data',"version: $version num: $num search: $search command: $cmd") if $b_log; + # special case, in rare instances version comes from file + if ($version ne 'file'){ + $output = qx($cmd); + main::log_data('data',"output: $output") if $b_log; + } + # print "cmd: $cmd\noutput:\n$output\n"; + # sample: dwm-5.8.2, ©.. etc, why no space? who knows. Also get rid of v in number string + # xfce, and other, output has , in it, so dump all commas and parentheses + if ($output){ + open(my $ch, '<', \$output) or main::error_handler('open-data',"$cmd", "$!"); + while (<$ch>){ + #chomp; + last if $count > $exit; + if ($_ =~ /$search/i){ + $_ = main::trimmer($_); + # print "loop: $_ :: num: $num\n"; + $_ =~ s/$replace//i if $replace; + $_ =~ s/\s/_/g if $b_no_space; # needed for some items with version > 1 word + my @data = split(/\s+/, $_); + $version_nu = $data[$num]; + last if ! defined $version_nu; + # some distros add their distro name before the version data, which + # breaks version detection. A quick fix attempt is to just add 1 to $num + # to get the next value. + $version_nu = $data[$num+1] if $data[$num+1] && $version_nu =~ /version/i; + $version_nu =~ s/(\([^)]+\)|,|"|\||\(|\))//g if $version_nu; + # trim off leading v but only when followed by a number + $version_nu =~ s/^v([0-9])/$1/i if $version_nu; + # print "$version_nu\n"; + last; + } + $count++; + } + close $ch if $ch; + } + main::log_data('data',"Program version: $version_nu") if $b_log; + eval $end if $b_log; + return $version_nu; +} +# print version('bash', 'bash', 4) . "\n"; + +# returns ($cmdd, $b_no_space) +# ksh: Version JM 93t+ 2010-03-05 [OR] Version A 2020.0.0 +# mksh: @(#)MIRBSD KSH R56 2018/03/09; lksh/pdksh: @(#)LEGACY KSH R56 2018/03/09 +# loksh: @(#)PD KSH v5.2.14 99/07/13.2; posh: 0.13.2 +sub version_cmd { + eval $start if $b_log; + my ($app,$app_name,$extra) = @_; + my @data = ('',0); + if ($app_name eq 'cicada'){ + $data[0] = $app . ' -c "' . $extra . '" 2>/dev/null';} + elsif ($app_name =~ /^(|l|lo|m|pd)ksh(93)?$/){ + $data[0] = $app . ' -c \'printf %s "$KSH_VERSION"\' 2>/dev/null'; + $data[1] = 1;} + elsif ($app_name eq 'posh'){ + $data[0] = $app . ' -c \'printf %s "$POSH_VERSION"\' 2>/dev/null'} + # print "$data[0] :: $data[1]\n"; + eval $end if $b_log; + return @data; +} + +# returns $cmd, $search +sub version_pkg { + eval $start if $b_log; + my ($app) = @_; + my ($program,@data); + # note: version $num is 3 in dpkg-query/pacman/rpm, which is convenient + if ($program = main::check_program('dpkg-query')){ + $data[0] = "$program -W -f='\${Package}\tversion\t\${Version}\n' $app 2>/dev/null"; + $data[1] = "^$app\\b"; + } + elsif ($program = main::check_program('pacman')){ + $data[0] = "$program -Q --info $app 2>/dev/null"; + $data[1] = '^Version'; + } + elsif ($program = main::check_program('rpm')){ + $data[0] = "$program -qi --nodigest --nosignature $app 2>/dev/null"; + $data[1] = '^Version'; + } + # print "$data[0] :: $data[1]\n"; + eval $end if $b_log; + return @data; +} +} + ## PsData # public subs: set_cmd(); set_gui() { @@ -34455,21 +34475,25 @@ sub set_cmd { } # we want more data from ps busybox, to get TinyX screen res my $cols_use = ($b_busybox) ? 7 : 2; + my $pattern = 'apache|brave|chrom(e|ium)|falkon|(fire|water)fox|gvfs|http|'; + $pattern .= 'konqueror|mariadb|mysql|openvpn|opera|pale|postgre|php|'; + $pattern .= 'qtwebengine|smbd|smtp|sssd|vivald'; for (@$ps){ next if !$_; next if $self_name eq 'inxi' && /\/$self_name\b/; $_ = lc; push (@ps_aux,$_); my @split = split(/\s+/, $_); - # slice out 10th to last elements of ps aux rows + # slice out COMMAND to last elements of psrows my $final = $#split; # some stuff has a lot of data, chrome for example $final = ($final > ($ps_data{'header'}->[0] + $cols_use)) ? $ps_data{'header'}->[0] + $cols_use : $final; # handle case of ps wrapping lines despite ww unlimited width, which - # should NOT be happening, but is. + # should NOT be happening, except on busybox ps, which has no ww. next if !defined $split[$ps_data{'header'}->[0]]; - if ($split[$ps_data{'header'}->[0]] !~ /^\[/){ + # we don't want zombie/system/kernel processes, or servers, browsers. + if ($split[$ps_data{'header'}->[0]] !~ /^([\[\(]|(\S+\/|)($pattern))/i){ push(@ps_cmd,join(' ', @split[$ps_data{'header'}->[0] .. $final])); } } @@ -34478,6 +34502,16 @@ sub set_cmd { eval $end if $b_log; } +# only runs when no dm found +sub set_dm { + eval $start if $b_log; + # startx: /bin/sh /usr/bin/startx + process_gui(\@{$ps_data{'dm-active'}},qw(ly startx xinit)); # possible dm values + print '$ps_data{dm-active}: ', Data::Dumper::Dumper $ps_data{'dm-active'} if $dbg[5]; + main::log_data('dump','$ps_data{dm-active}',$ps_data{'dm-active'}) if $b_log; + eval $end if $b_log; +} + sub set_gui { eval $start if $b_log; $loaded{'ps-gui'} = 1; @@ -34508,16 +34542,14 @@ sub set_gui { deepin-metacity metacity metisse mir muffin deepin-mutter mutter ukwm xfwm[45]?); push(@match,@temp); - # startx: /bin/sh /usr/bin/startx - process_gui(\@{$ps_data{'dm-active'}},qw(ly startx xinit)); # possible dm values } # info: NOTE: glx-dock is cairo-dock if ($show{'system'} && $extra > 2){ process_gui(\@{$ps_data{'info-active'}},join('|', qw( - alltray awesomebar awn bar bmpanel bmpanel2 budgie-panel cairo-dock + alltray awesomebar awn bar bemenu bmpanel bmpanel2 budgie-panel cairo-dock dde-dock dmenu dockbarx docker docky dzen dzen2 fbpanel fspanel - glx-dock gnome-panel hpanel i3bar i3-status(-rs)? icewmtray kdocker kicker - latte latte-dock lemonbar ltpanel luastatus lxpanel lxqt-panel + glx-dock gnome-panel hpanel i3bar i3-status(-rs|-rust)? icewmtray + kdocker kicker latte latte-dock lemonbar ltpanel luastatus lxpanel lxqt-panel matchbox-panel mate-panel nwg-bar nwg-dock nwg-panel ourico perlpanel plank plasma-desktop plasma-netbook polybar pypanel razor-panel razorqt-panel rootbar sfwbar stalonetray swaybar @@ -34547,13 +34579,13 @@ sub set_gui { if ($b_wl){ # wayland compositors generally are compositors and wm. # These will be used globally to avoid having to redo it over and over. - $ps_data{'wl-comp'} = '|' . join('|',qw(asc awc + $ps_data{'wl-comp'} = '|' . join('|',qw(asc awc bismuth cage cagebreak cardboard chameleonwm clayland comfc - dwc dwl epd-wm fireplace feathers fenestra glass gamescope greenfield grefson + dwl dwc epd-wm fireplace feathers fenestra glass gamescope greenfield grefson hikari hopalong [Hh]yprland inaban japokwm kiwmi labwc laikawm lipstick liri - mahogany marina maze motorcar newm nucleus - orbital orbment perceptia phoc pywm qtile river rootston rustland - simulavr skylight smithay sommelier sway swc swvkc + mahogany marina maze maynard motorcar newm nucleus + orbital orbment perceptia phoc polonium pywm qtile river rootston rustland + simulavr skylight smithay sommelier sway swayfx swc swvkc tabby taiwins tinybox tinywl trinkster velox vimway vivarium wavy waybox way-?cooler wayfire wayhouse waymonad westeros westford weston wio\+? wxr[cd] xuake)); @@ -34869,7 +34901,7 @@ sub set { # do nothing, just leave $shell as is } # note: not all programs return version data. This may miss unhandled shells! - elsif ((@app = main::program_data(lc($shell),lc($shell),1)) && $app[0]){ + elsif ((@app = ProgramData::full(lc($shell),lc($shell),1)) && $app[0]){ $shell = $app[0]; $client{'version'} = $app[1] if $app[1]; print "3: app test $shell v: $client{'version'}\n" if $b_debug; @@ -34888,7 +34920,7 @@ sub set { if (shell_test($parent)){ $shell = $parent; } - elsif ((@app = main::program_data(lc($parent),lc($parent),0)) && $app[0]){ + elsif ((@app = ProgramData::full(lc($parent),lc($parent),0)) && $app[0]){ $shell = $app[0]; $client{'version'} = $app[1] if $app[1]; } @@ -34907,7 +34939,7 @@ sub set { $client{'name-print'} = $shell; print "7: shell: $client{'name-print'} version: $client{'version'}\n" if $b_debug; if ($extra > 2 && $working && lc($shell) ne lc($working)){ - if (@app = main::program_data(lc($working))){ + if (@app = ProgramData::full(lc($working))){ $client{'default-shell'} = $app[0]; $client{'default-shell-v'} = $app[1]; $client{'default-shell-v'} =~ s/(\s*\(.*|-release|-version)// if $client{'default-shell-v'}; @@ -36768,7 +36800,7 @@ sub info_item { } my $clang_version = ''; if (my $path = main::check_program('clang')){ - $clang_version = main::program_version($path,'clang',3,'--version'); + $clang_version = ProgramData::version($path,'clang',3,'--version'); $clang_version ||= 'N/A'; $b_clang = 1; }