summaryrefslogtreecommitdiffstats
path: root/.local/bin/dmapps
blob: 527cb5b2219e1af683a89f70fcdd3e5181bc0138 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/env perl

use strict;
use warnings;
use Data::Dump qw(dump);
use Env qw(TERMINAL);
use POSIX qw(setsid);
use Sys::Hostname qw(hostname);

use constant PROG_LIST	=> "" .
"Terminal"				. "\n" .
"File manager"			. "\n" .
"Web browser"			. "\n" .
"Mail client"			. "\n" .
"--- Accessories ---"	. "\n" .
"Qalculate!"			. "\n" .
"Kleopatra"				. "\n" .
"Transmission"			. "\n" .
"Wireshark"				. "\n" .
"MKVToolNix"			. "\n" .
"Google Earth"			. "\n" .
"--- Editors ---"		. "\n" .
"NeoVim"				. "\n" .
"Emacs"					. "\n" .
"Emacs-NoX"				. "\n" .
""	;
use constant WORK_LIST	=> "" .
"--- Work ---"	. "\n" .
"Remmina"		. "\n" .
"Insomnia"		. "\n" .
"VMware"		. "\n" .
"miro"			. "\n";

sub run
{
	my ($action) = @_;
	my $pid;

	chomp($action);
	# Terminal
	if ($action eq "Terminal") {
		$pid = fork();
		exit if $pid;
		setsid();
		exec("alacritty");
	}
	# File manager
	elsif ($action eq "File manager") {
		$pid = fork();
		exit if $pid;
		setsid();
		exec("pcmanfm");
	}
	# Web browser
	elsif ($action eq "Web browser") {
		$pid = fork();
		exit if $pid;
		setsid();
		exec("librewolf");
	}
	# Mail client
	elsif ($action eq "Mail client") {
		$pid = fork();
		exit if $pid;
		setsid();
		exec("thunderbird");
	}
	# --- Accessories ---
	# Qalculate!
	elsif ($action eq "Qalculate!") {
		$pid = fork();
		exit if $pid;
		setsid();
		exec("qalculate-gtk");
	}
	# Kleopatra
	elsif ($action eq "Kleopatra") {
		$pid = fork();
		exit if $pid;
		setsid();
		exec("kleopatra");
	}
	# Transmission
	elsif ($action eq "Transmission") {
		$pid = fork();
		exit if $pid;
		setsid();
		exec("transmission-gtk");
	}
	# Wireshark
	elsif ($action eq "Wireshark") {
		$pid = fork();
		exit if $pid;
		setsid();
		exec("doas", "wireshark");
	}
	# MKVToolNix
	elsif ($action eq "MKVToolNix") {
		$pid = fork();
		exit if $pid;
		setsid();
		exec("mkvtoolnix-gui");
	}
	# Google Earth
	elsif ($action eq "Google Earth") {
		$pid = fork();
		exit if $pid;
		setsid();
		exec("google-earth-pro");
	}
	# --- Editors ---
	# NeoVim
	elsif ($action eq "NeoVim") {
		$pid = fork();
		exit if $pid;
		setsid();
		exec($TERMINAL, "-e", "nvim");
	}
	# Emacs
	elsif ($action eq "Emacs") {
		$pid = fork();
		exit if $pid;
		setsid();
		exec("emacs");
	}
	# Emacs-NoX
	elsif ($action eq "Emacs-NoX") {
		$pid = fork();
		exit if $pid;
		setsid();
		exec($TERMINAL, "-e", "emacs-nw");
	}
	return;
}

sub main
{
	my $action;
	my $prompt;

	$prompt = PROG_LIST;
	if (hostname() eq "po-rbo.ln.ysosecure.com") {
		$prompt .= WORK_LIST;
	}
	$action = `dmenu -i -l 25 -m 0 <<LIST
$prompt
LIST`;
	if (not $action) {
		return;
	}
	run($action);
	return;
}

main();

__END__