summaryrefslogtreecommitdiff
path: root/src/corelib/x11/fpg_utils_impl.inc
blob: d8625b8c2c6bb261bb11a48c13ae88e5cf60cd37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{%mainunit fpg_utils.pas}

uses
  Unix;

// X11 specific filesystem implementations of encoding functions

function fpgToOSEncoding(aString: TfpgString): string;
begin
  Result := aString;
end;

function fpgFromOSEncoding(aString: string): TfpgString;
begin
  Result := aString;
end;

procedure fpgOpenURL(const aURL: TfpgString);
var
  Helper: string;
begin
//TODO: Catch "which" command output to run the browser from there
  Helper := '';
  if fpsystem('which xdg-open') = 0 then
    Helper := 'xdg-open'
  else if FileExists('/usr/bin/sensible-browser') then
    Helper := '/usr/bin/sensible-browser'
  else if FileExists('/etc/alternatives/x-www-browser') then
    Helper := '/etc/alternatives/x-www-browser'
  else if fpsystem('which firefox') = 0 then
    Helper := 'firefox'
  else if fpsystem('which konqueror') = 0 then
    Helper := 'konqueror'
  else if fpsystem('which opera') = 0 then
    Helper := 'opera'
  else if fpsystem('which mozilla') = 0 then
     Helper := 'mozilla';

  if Helper <> '' then
    fpSystem(Helper + ' ' + aURL + '&');
end;