1#!/bin/sh
2# Ultra primitive config generator. Improvements (like parsing .desktop files or
3# a proper implementation of the XDG icon convention) highly welcome.
4
5gen_button () # $1 -> bin, $2 -> icon
6{
7	[ -z "${1}" ] && return;
8	[ -z "${2}" ] && return;
9
10	cat << EOF | sed "s|@icon@|${2}|g" | sed "s|@bin@|${1}|g"
11	button
12	{
13		image-path          = "@icon@";
14		command[mouse-left] = "@bin@";
15	}
16
17EOF
18}
19
20# Let's start by blurping out the configuration boilerplate
21cat << EOF
22# Autogenerated example config file.
23# It uses a very rough and naive method for finding icons,
24# so don't be surprised if those come out a bit weird.
25# For details regarding the configuration please read lavalauncher(1)
26
27global-settings
28{
29	watch-config-file = false;
30}
31
32bar
33{
34	alignment               = center;
35	background-colour       = "#202020";
36	border                  = 1 1 1 1;
37	cursor-name             = pointer;
38	exclusive-zone          = true;
39	hidden-mode             = never;
40	hidden-size             = 10;
41	icon-padding            = 4;
42	indicator-active-colour = "#606060";
43	indicator-hover-colour  = "#606060";
44	indicator-padding       = 0;
45	indicator-style         = rounded-rectangle;
46	layer                   = top;
47	margin                  = 0;
48	mode                    = default;
49	namespace               = LavaLauncher;
50	position                = bottom;
51	radius                  = 5;
52	size                    = 60;
53
54	condition-resolution = wider-than-high;
55	condition-scale      = all;
56	condition-transform  = all;
57
58	config
59	{
60		condition-resolution = higher-than-wide;
61		radius               = 0;
62		mode                 = full;
63	}
64
65EOF
66
67# Now how about a terminal?
68ICON="$(find /usr/share/icons/ -type f -name *term* | head -1)"
69BIN="$(which alacritty foot xterm terminator gnome-terminal 2> /dev/null | head -1)"
70gen_button "$BIN" "$ICON"
71
72# Now how about a browser?
73ICON="$(find /usr/share/icons/ -type f -name *web* | head -1)"
74BIN="$(which firefox iceweasel chromium chrome 2> /dev/null | head -1)"
75gen_button "$BIN" "$ICON"
76
77# Now how about an editor?
78ICON="$(find /usr/share/icons/ -type f -name *edit* | head -1)"
79BIN="$(which emacs acme kate gedit mousepad 2> /dev/null | head -1)"
80gen_button "$BIN" "$ICON"
81
82# Now how about a filemanager?
83ICON="$(find /usr/share/icons/ -type f -name *dire* | head -1)"
84BIN="$(which nautilus nemo thunar pcmanfm 2> /dev/null | head -1)"
85gen_button "$BIN" "$ICON"
86
87# Now how about audio configuration?
88ICON="$(find /usr/share/icons/ -type f -name *audio* | head -1)"
89BIN="$(which pavucontrol 2> /dev/null | head -1)"
90gen_button "$BIN" "$ICON"
91
92# Now how about general configuration?
93ICON="$(find /usr/share/icons/ -type f -name *conf* | head -1)"
94BIN="$(which lxappearance dconf-editor 2> /dev/null | head -1)"
95gen_button "$BIN" "$ICON"
96
97# Now how about some games?
98ICON="$(find /usr/share/icons/ -type f -name *gam* | head -1)"
99BIN="$(which wesnoth supertuxkart gnome-mines gnome-chess 2> /dev/null | head -1)"
100gen_button "$BIN" "$ICON"
101
102# Now how about that one disk utility?
103ICON="$(find /usr/share/icons/ -type f -name *disk* | head -1)"
104BIN="$(which gnome-disks baobab 2> /dev/null | head -1)"
105gen_button "$BIN" "$ICON"
106
107# And let's end it here
108echo "}"
109
110