-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstart-hello
executable file
·273 lines (229 loc) · 9.1 KB
/
start-hello
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#!/bin/sh
# This script is intended to be invoked by a desktop file
# from /usr/local/share/xsessions
# where the display manager (login window) picks it up
# Find out whether we are running in a virtual machine
VM_GUEST=$(/sbin/sysctl -n kern.vm_guest)
HV_VENDOR=$(/sbin/sysctl -n hw.hv_vendor | /usr/bin/awk '{print $1}')
if [ "${VM_GUEST}" = "xen" ]; then
VIRTUAL_MACHINE=YES
fi
if [ "${VM_GUEST}" = "vmware" ]; then
VIRTUAL_MACHINE=YES
fi
if [ "${VM_GUEST}" = "kvm" ]; then
VIRTUAL_MACHINE=YES
fi
if [ "${HV_VENDOR}" = "bhyve" ]; then
VIRTUAL_MACHINE=YES
fi
if [ -f "/usr/sbin/pciconf" ] ; then
/usr/sbin/pciconf -lv 2>/dev/null | /usr/bin/grep -q VirtualBox 2>/dev/null
if [ $? -eq 0 ] ; then
VIRTUAL_MACHINE=YES
fi
fi
if [ -f "/usr/sbin/pciconf" ] ; then
/usr/sbin/pciconf -lv 2>/dev/null | /usr/bin/grep -q VMware 2>/dev/null
if [ $? -eq 0 ] ; then
VIRTUAL_MACHINE=YES
fi
fi
if [ -f "/usr/sbin/pciconf" ] ; then
/usr/sbin/pciconf -lv 2>/dev/null | /usr/bin/grep -q QXL 2>/dev/null
if [ $? -eq 0 ] ; then
VIRTUAL_MACHINE=YES
fi
fi
# Disable core dumps for applications
ulimit -c 0
# Enable FUSE and allow non-root users to mount, which gvfs requires to work
# FIXME: Remove the need for those lines in this script; how?
# FIXME: It will not work in installed mode like this, because the user may not be able to use sudo without entering a password
sudo sysctl vfs.usermount=1 || true
sudo kldload fuse.ko || true # FreeBSD up to 12.x
sudo kldload fusefs.ko || true # FreeBSD 13+, violates POLA
# Prevent Gnome-related processes at-spi-bus-launcher
# and at-spi2-registryd from bleeding into our system
# https://bbs.archlinux.org/viewtopic.php?pid=1789644#p1789644
export NO_AT_BRIDGE=1
# Start D-Bus and export DBUS_SESSION_BUS_ADDRESS;
# this is needed for D-Bus Activation to work, which gvfs requires to work
if [ -z $DBUS_SESSION_BUS_ADDRESS ] ; then
export $(dbus-launch)
fi
# Set locale if it is not set already
# and if /usr/local/var/localize/include exists
# (might have been created by the localize script during boot)
# On FreeBSD before 13, $LANG is unset. Starting with 13, it is "C.UTF-8" when it is not specified. This is not POLA
if [ -f "/usr/local/etc/X11/xorg.conf.d/00-keyboard.conf" ] ; then
echo "Skipping keyboard autoconfiguration because /usr/local/etc/X11/xorg.conf.d/00-keyboard.conf exists"
else
if [ -z "${LANG}" ] || [ "C.UTF-8" = "${LANG}" ] ; then
if [ -e "/usr/local/var/localize/include" ] ; then
. /usr/local/var/localize/include
export LANG
export MM_CHARSET
export TZ # This leads to correct time, and to time/date formatting
COUNTRY=$(echo "${LANG}" | cut -d _ -f 2 | cut -d "." -f 1 | tr '[A-Z]' '[a-z]')
setxkbmap -layout "${COUNTRY}"
setxkbmap -variant nodeadkeys 2>/dev/null
setxkbmap -query
fi
fi
fi
# Use sysmouse if there is a problem with the touchpad; Credits: NomadBSD
tpquirk
# Enable tapping on touchpad; Credits: NomadBSD
enable_tapping
# Swap keys:
# On both PC and Apple keyboards, the key left from the space bar
# shall be used to invoke menu shortcuts (which applications tend to
# put on "Ctrl"). Cleaner ways to accomplish this would be welcome.
# TODO: Make this possible to change in the GUI due to popular request
# no matter what is printed on it
# TODO: Make this per-keyboard so that one can have Apple and PC keyboards
# attached at the same time while each one gets its correct treatment
# TODO: Make this hot-pluggable so that keyboards can come and go
# NOTE: In Linux, the driver for Apple keyboards has an option to do this swap
# directly in the kernel driver
DONOTSWAPCOMMANDKEY=$(grep -r "DoNotSwapCommandKey=true" ~/.config/hello/keyboard.conf)
if [ -z "${DONOTSWAPCOMMANDKEY}" ] ; then
APPLE_KEYBOARD_DETECTED=$(sysctl kern.evdev.input | grep Apple | grep Keyboard)
if [ -z "${APPLE_KEYBOARD_DETECTED}" ] ; then
# On PC keyboards, swap Ctrl and Alt
# FIXME: How to do this also for the right-hand side?
setxkbmap -option ctrl:swap_lalt_lctl
else
# On Apple keyboards, swap Ctrl and Command
setxkbmap -option ctrl:swap_lwin_lctl,ctrl:swap_rwin_rctl
fi
fi
# Disable Caps Lock key
DONOTDISABLECAPSLOCK=$(grep -r "DoNotDisableCapslockKey=true" ~/.config/hello/keyboard.conf)
if [ -z "${DONOTDISABLECAPSLOCK}" ] ; then
setxkbmap -option caps:none
fi
# Export XDG environment variables,
# these may be used by applications that run inside the desktop session
HERE="$(dirname "$(readlink -f "${0}")")"
export XDG_CACHE_HOME=~/.cache
export XDG_CONFIG_DIRS=/etc:/usr/local/etc/xdg:/usr/share:/usr/local/share
export XDG_CONFIG_HOME=~/.config
export XDG_DATA_DIRS=~/.local/share:/usr/local/share:/usr/share
export XDG_DATA_HOME=~/.local/share
export XDG_SESSION_CLASS=user
export XDG_SESSION_TYPE=x11
# When 'sudo -A -E <command>' is executed, use this helper appliction to get the password
export SUDO_ASKPASS=/usr/local/bin/askpass
# Using sudo.conf resulted in a password dialog when X starts
# Ensure users are never dropped into vi
export VISUAL=/usr/local/bin/nano
export EDITOR=/usr/local/bin/nano
##################
# Global menus for Gtk applications
#
# https://github.com/rilian-la-te/vala-panel-appmenu/blob/master/subprojects/appmenu-gtk-module/README.md
##################
if [ -n "$GTK_MODULES" ]; then
GTK_MODULES="${GTK_MODULES}:appmenu-gtk-module"
else
GTK_MODULES="appmenu-gtk-module"
fi
if [ -z "$UBUNTU_MENUPROXY" ]; then
UBUNTU_MENUPROXY=1
fi
export GTK_MODULES
export UBUNTU_MENUPROXY
# Export other environment variables
export QT_QPA_PLATFORMTHEME=panda
# Calculate DPI and determine whether we have a HiDPI screen. TODO: Is there a better way?
# Get vertical size in cm
vertical_cm=$(cat /var/log/Xorg.0.log | grep "Max Image Size \[cm\]" | rev | cut -d ":" -f 1 | rev | xargs | tail -n 1)
# Get vertical size in inches, return int; man units
vertical_inches=$(units -q -t ${vertical_cm}" cm" inches | cut -d "." -f 1)
# echo "${vertical_inches}"
vertical_pixels=$(cat /var/log/Xorg.0.log | grep "using initial mode" | cut -d x -f 2 | cut -d " " -f 1 | xargs | tail -n 1)
# echo "${vertical_pixels}"
dpi=$(expr "${vertical_pixels}" / "${vertical_inches}")
# echo "${dpi}"
# On some systems, vertical_cm and/or vertical_pixels may not be there; in this case do not assume HiDPI
if [ "${dpi}" -gt 200 ] && [ ! -z "${vertical_cm}" ] && [ ! -z "${vertical_pixels}" ] ; then
echo "Assuming HiDPI"
HIDPI="YES"
else
echo "Not assuming HiDPI"
fi
if [ "$HIDPI" != "" ] ; then
export QT_SCALE_FACTOR=2
# Export high-DPI settings:
# QT_ENABLE_HIGHDPI_SCALING sice Qt 5.14 enables automatic scaling
# based on the pixel density of the monitor.
# Replaces QT_AUTO_SCREEN_SCALE_FACTOR.
# https://lists.qt-project.org/pipermail/development/2019-September/037434.html
# export QT_ENABLE_HIGHDPI_SCALING=1 # Does not really seem to do anything? Because Xorg always sets DPI to 96 regardless of the facts
export GDK_SCALE=2 # Working, but only for ints
# export GDK_DPI_SCALE=1.5 # Not working
# See https://ricostacruz.com/til/fractional-scaling-on-xorg-linux for a possible solution
# for other scaling factors
fi
# Launch per-user daemons
# Global keyboard shortcuts
# It reads its configuration from
# ${XDG_CONFIG_HOME}/lxqt/globalkeyshortcuts.conf
# --config-file=FILENAME can be used several times, the last one is used for saving
# TODO: Move this functionality into Menu?
/usr/local/bin/lxqt-globalkeysd &
# Drop shadows
/usr/local/bin/picom --dbus &
# Window decorations
if [ "$HIDPI" = "" ] ; then
xrdb -load ~/.Xresources # Ensure a constant font DPI setting; https://linuxreviews.org/HOWTO_set_DPI_in_Xorg
/usr/local/bin/openbox --config-file ~/.openbox &
else
xrdb -load ~/.Xresources-2x # Also change cursor size
/usr/local/bin/openbox --config-file ~/.openbox-2x &
fi
# Desktop notifications
dunst &
# Sound mixer on FreeBSD; would need a space to show tray icons in Menubar;
# should possibly be launched by it if available?
# dsbmixer -i
# Battery monitor, same
# dsbbatmon
# Same for
# dsbmc
# Variable color temperature
# without getlalo it would use network locatization from geoclue2,
# with getlalo it gets the location from /var/db/zoneinfo
# which we posssibly should set in the Welcome Wizard,
# but then the color would be wrong for the Welcome Wizard
# Do not run this if we are running inside a virtual machine
if [ -z "$VIRTUAL_MACHINE" ] ; then
redshift -l$(getlalo) &
fi
# Welcome Wizard
uid="$(id -u)"
if [ -e /System/Welcome.app/Welcome ] ; then
if [ ! -e "${HOME}/.config/hello/.helloSetupDone" ] ; then
/System/Welcome.app/Welcome
fi
fi
# Menubar
export GTK_MODULES=appmenu-gtk-module
/usr/local/bin/menubar &
# FIXME: Does the next line have to run AFTER menubar?
# Else we see no QMenus at all, as if something was badly crashing?
### "${HERE}"/dde-globalmenu-service & # gmenudbusmenuproxy without Plasma deps
/usr/local/bin/gmenudbusmenuproxy-standalone &
# Desktop
/usr/local/bin/filer-qt --desktop &
# Per-user autostart
# for APP in ~/Applications/Autostart/* ; do
# echo "Autostarting ${APP}"
# launch "${APP}" &
# done
/usr/local/bin/cyber-dock
# Here we must start something that never exits;
# the session ends when that thing exits
read 1