summaryrefslogtreecommitdiffstats
path: root/.local/bin/dmbookm
blob: 4b1332efae396d19a3acbde7f5aad3a62e177b17 (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
43
44
45
46
47
48
49
50
#!/usr/bin/env perl

use strict;
use warnings;
use Sys::Hostname;

use constant {
	BROWSER		=> '/bin/firefox',
	HOSTNAME	=> (split /\./, hostname())
};

use constant LIST => [
	['grafana',			'https://grafana.nuabee.fr/'],
	['graf',			'http://graf.joe.town/'],
	['hedgedoc',		'http://hedgedoc.int.ysosecure.com/'],
	['zammad',			'https://support.nuabee.fr/'],
	[],
	];

sub main
{
	my $choice;
	my $url;
	my $pid;
	my $prefix;
	my $list;

	$prefix = '/usr';
	if (HOSTNAME eq "mars") {
		$prefix += '/local';
	}
	for (@{+LIST}) {
		$list .= $_ . "\n";
	}
	$choice = `printf "" | dmenu -i -m 0 -l 100`;
	if (not $choice) {
		return;
	}
	$choice =~ s/ /+/g;
	$url =  . $choice;
	$pid = fork();
	if (not $pid) {
		exec($prefix . BROWSER, $url);
	}
	return;
}

main();

__END__