]> git.mar77i.info Git - laptop-config/blob - generate-desktop-files.sh
initial commit
[laptop-config] / generate-desktop-files.sh
1 #!/usr/bin/env bash
2
3 cd "$(dirname "$(realpath -Pe "${0}")")"
4 find . -name '*.desktop' -delete
5
6 setup_screens=
7
8 while (( ${#} )); do
9 if [[ -x "${1}" ]]; then
10 if [[ "${setup_screens}" ]]; then
11 echo "Error: script path set twice" >&2
12 exit 1
13 fi
14 setup_screens="$(realpath -Pe "${1}")"
15 fi
16 shift
17 done
18
19 if [[ -z "${setup_screens}" || ! -x "${setup_screens}" ]]; then
20 echo "Error: script path not set or does not exist" >&2
21 exit 1
22 fi
23
24 get_icon_config() {
25 local svg_file="$(dirname "${setup_screens}")/laptop-${REPLY,,}.svg"
26 if [[ -e "${svg_file}" ]]; then
27 echo "Icon=${svg_file}"
28 else
29 echo "#Icon=${svg_file}"
30 fi
31 }
32
33 while read -r -d $'\n'; do
34 cat >"${REPLY}.desktop" <<EOF
35 [Desktop Entry]
36 Type=Application
37 Exec=${setup_screens} --wait-for-keypress --load-saved ${REPLY}
38 $(get_icon_config "${RPELY}")
39
40 Name=Restore saved monitor settings ${REPLY}
41 Terminal=true
42 EOF
43 done < <(lxqt-config-monitor --list-saved 2>/dev/null)