summaryrefslogtreecommitdiffstats
path: root/.local/bin/dmbookm
blob: 2bfeb21ff966ad60c8f7b66efa184c0a2e834758 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env perl

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

# debug
use Data::Dumper;

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

use constant LIST => {
	graf					=> 'http://graf.joe.town/',
	zhinu					=> 'https://zhinu.jozan.org/',
	perplexity				=> 'https://perplexity.ai/',
	chatgpt					=> 'https://chatgpt.com/',
	discord					=> 'https://discord.com/',
	protondb				=> 'https://www.protondb.com/',
	nua_grafana				=> 'https://grafana.nuabee.fr/',
	nua_gr_linux_servers	=> 'https://grafana.nuabee.fr/d/xfpJB9FGz/linux-servers',
	nua_gr_restops			=> 'https://grafana.nuabee.fr/d/Mz11bd07k/vue-d-ensemble-machines-atelier',
	nua_gr_alertops			=> 'https://grafana.nuabee.fr/d/WojOgXTmk/ops-alerts',
	nua_git					=> 'https://gitlab.int.ysosecure.com/',
	nua_mbs					=> 'https://mbs.nuabee.com/',
	nua_hedgedoc			=> 'http://hedgedoc.int.ysosecure.com/',
	nua_doc					=> 'https://doc.int.ysosecure.com/',
	nua_kb					=> 'https://kb.int.ysosecure.com/',
	nua_zammad				=> 'https://support.nuabee.fr/',
	nua_atlas				=> 'https://atlas.nuabee.fr/',
	nua_share				=> 'https://share.nuabee.fr/',
};

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

	$color = '#cc241d';
	if (@ARGV == 1) {
		$color = $ARGV[0];
	}
	$prefix = '/usr';
	if (HOSTNAME eq "mars") {
		$prefix += '/local';
	}
	for (keys %{LIST()}) {
		$list .= $_ . "\n";
	}
	$choice = `printf "$list" | dmenu -i -l 100 -sb '$color' -shb '$color'`;
	if (not $choice) {
		return;
	}
	chomp $choice;
	$pid = fork();
	if (not $pid) {
		exec($prefix . BROWSER, LIST->{$choice});
	}
	return;
}

main();

__END__