Debian Codegraph @

src/session/startbudgielabwc.in

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/usr/bin/env bash
2 OPTS=""
3 for OPT in "$@"; do
4 if test "${OPT}" = "--help"; then
5 # Print help and exit
6 echo "Usage:"
7 echo " startbudgielabwc [OPTIONS...]"
8 echo
9 echo "Options:"
10 echo " --help Show help options"
11 echo
12
13 exit 0
14 else
15 # Append to opts
16 OPTS="$OPTS $OPT"
17 fi
18 done
19
20 # Set the XDG_RUNTIME_DIR if we can not get it in systems
21 # without systemd
22 if [ -z "${XDG_RUNTIME_DIR}" ]; then
23 if [ -d "/run/user" ]; then
24 XDG_RUNTIME_DIR="/run/user/$(id -ru)"
25 export XDG_RUNTIME_DIR
26 else
27 if [ -d "/var/run/user" ]; then
28 XDG_RUNTIME_DIR="/var/run/user/$(id -ru)"
29 export XDG_RUNTIME_DIR
30 else
31 XDG_RUNTIME_DIR="/tmp/${USER}-runtime"
32 export XDG_RUNTIME_DIR
33 fi
34 fi
35 fi
36
37 if [ ! -e "${XDG_RUNTIME_DIR}" ]; then
38 logger "XDG_RUNTIME_DIR is invalid or does not exist!"
39 logger "Creating XDG_RUNTIME_DIR..."
40 mkdir -p -m 0700 "${XDG_RUNTIME_DIR}" || {
41 logger "Unable to create runtime directory ${XDG_RUNTIME_DIR}!"
42 exit 1
43 }
44 fi
45
46 # Fix desktop file override precedence
47 if [ -z "$XDG_DATA_DIRS" ]; then
48 export XDG_DATA_DIRS="@datadir@/budgie-desktop:@datadir@"
49 else
50 case ":$XDG_DATA_DIRS:" in
51 *":@datadir@/budgie-desktop:"*) ;;
52 *)
53 export XDG_DATA_DIRS="@datadir@/budgie-desktop:$XDG_DATA_DIRS"
54 ;;
55 esac
56 fi
57
58 # freedesktop specifications mandate that the definition
59 # of XDG_SESSION_TYPE should be respected
60 XDG_SESSION_TYPE="wayland"
61 export XDG_SESSION_TYPE
62 # Make sure all toolkits use their Wayland backend
63 #
64 # For Gtk applications also the x11 backend as a safe fallback
65 if [ -z "${GDK_BACKEND}" ]; then
66 GDK_BACKEND="wayland,x11"
67 export GDK_BACKEND
68 fi
69 if [ -z "${QT_QPA_PLATFORM}" ]; then
70 QT_QPA_PLATFORM="wayland"
71 export QT_QPA_PLATFORM
72 fi
73
74 # allow compatible Qt6 apps to theme with gtk3
75 if [ -z "${QT_QPA_PLATFORMTHEME}" ]; then
76 QT_QPA_PLATFORMTHEME="gtk3"
77 export QT_QPA_PLATFORMTHEME
78 fi
79
80 # In many OS the wayland backend for clutter does not work, so
81 # use the safe "gdk" backend instead
82 if [ -z "${CLUTTER_BACKEND}" ]; then
83 CLUTTER_BACKEND="gdk"
84 export CLUTTER_BACKEND
85 fi
86 if [ -z "${SDL_VIDEODRIVER}" ]; then
87 SDL_VIDEODRIVER="wayland"
88 export SDL_VIDEODRIVER
89 fi
90
91 # Add a wlroots helper to allow running in VirtualBox
92 if grep -q "VirtualBox" /sys/class/dmi/id/product_name 2>/dev/null; then
93 export WLR_RENDERER=pixman
94 fi
95
96 if command -v eglinfo >/dev/null 2>&1; then
97 if eglinfo 2>/dev/null | grep -qi 'virgl'; then
98 export WLR_NO_HARDWARE_CURSORS=1
99 fi
100 fi
101
102 # Add a helper for electron based apps to think they are running under GNOME
103 export GNOME_DESKTOP_SESSION_ID=this-is-deprecated
104
105 # This is default for current firefox/thunderbird
106 MOZ_ENABLE_WAYLAND="1"
107 export MOZ_ENABLE_WAYLAND
108
109 default_compositor="labwc"
110
111 # Create specific labwc directory for Budgie
112 if [ ! -d "${XDG_CONFIG_HOME:-${HOME}/.config}/budgie-desktop/labwc" ]; then
113 mkdir -p "${XDG_CONFIG_HOME:-${HOME}/.config}/budgie-desktop/labwc"
114 fi
115
116 # Copy specific labwc configuration file for Budgie
117 if [ ! -f "${XDG_CONFIG_HOME:-${HOME}/.config}/budgie-desktop/labwc/rc.xml" ]; then
118 cp -p @datadir@/budgie-desktop/labwc/rc.xml "${XDG_CONFIG_HOME:-${HOME}/.config}/budgie-desktop/labwc/rc.xml"
119 # This is needed on some immutable distributions like NixOS.
120 chmod u+w "${XDG_CONFIG_HOME:-${HOME}/.config}/budgie-desktop/labwc/rc.xml"
121 fi
122
123 # Copy specific labwc environment file for Budgie
124 if [ ! -f "${XDG_CONFIG_HOME:-${HOME}/.config}/budgie-desktop/labwc/environment" ]; then
125 cp -p @datadir@/budgie-desktop/labwc/environment "${XDG_CONFIG_HOME:-${HOME}/.config}/budgie-desktop/labwc/environment"
126 chmod u+w "${XDG_CONFIG_HOME:-${HOME}/.config}/budgie-desktop/labwc/environment"
127 fi
128
129 # Copy specific labwc menu file for Budgie
130 if [ ! -f "${XDG_CONFIG_HOME:-${HOME}/.config}/budgie-desktop/labwc/menu.xml" ]; then
131 cp -p @datadir@/budgie-desktop/labwc/menu.xml "${XDG_CONFIG_HOME:-${HOME}/.config}/budgie-desktop/labwc/menu.xml"
132 chmod u+w "${XDG_CONFIG_HOME:-${HOME}/.config}/budgie-desktop/labwc/menu.xml"
133 fi
134
135 # Budgie will use its own config directory and config file to avoid
136 # conflict with current labwc setup and avoid launching anything
137 # from ~/.config/labwc/autostart
138 BUDGIE_SESSION_COMPOSITOR="${OPTS:-labwc --config-dir ${XDG_CONFIG_HOME:-${HOME}/.config}/budgie-desktop/labwc} -S budgie-desktop"
139
140 # Start a D-Bus session if there isn't one already.
141 if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
142 BUDGIE_SESSION_COMPOSITOR="dbus-run-session -- ${BUDGIE_SESSION_COMPOSITOR}"
143 fi
144
145 # workaround https://github.com/canonical/lightdm/issues/63
146 if [ -n "$XDG_VTNR" ] && [ -f "/sys/devices/virtual/tty/tty0/active" ]; then
147 VT_TEST_CNT=1
148 while true; do
149 CURRENT_VT=$(cat /sys/devices/virtual/tty/tty0/active)
150 if [ "$CURRENT_VT" = "tty$XDG_VTNR" ]; then
151 break
152 fi
153 VT_TEST_CNT=$((VT_TEST_CNT + 1))
154 if [ "$VT_TEST_CNT" -gt 100 ]; then
155 logger "VT $XDG_VTNR is expected but the switch did not happen in the last second, continuing anyway."
156 break
157 fi
158 sleep 0.01
159 done
160 fi
161
162 # start the budgie compositor
163 exec ${BUDGIE_SESSION_COMPOSITOR}
164
165 exit 0