about summary refs log tree commit diff
path: root/sh/matlab
diff options
context:
space:
mode:
authorXiao Pan <gky44px1999@gmail.com>2023-02-09 16:50:19 -0800
committerXiao Pan <gky44px1999@gmail.com>2023-02-09 16:50:19 -0800
commit6156db64bd38f5d3ba299c77df6268a1afed35f1 (patch)
tree8d1573311895e30a05e0cc9fa5e43763e78f7dd7 /sh/matlab
init
Diffstat (limited to 'sh/matlab')
-rwxr-xr-xsh/matlab31
1 files changed, 31 insertions, 0 deletions
diff --git a/sh/matlab b/sh/matlab
new file mode 100755
index 0000000..9df9e99
--- /dev/null
+++ b/sh/matlab
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# for matlab version R2022a
+# https://wiki.archlinux.org/title/MATLAB#Blank/grey_UI_when_using_WM_(non-reparenting_window_manager)
+# https://wiki.archlinux.org/title/Java#Gray_window,_applications_not_resizing_with_WM,_menus_immediately_closing
+# https://wiki.archlinux.org/title/MATLAB#Unable_to_launch_the_MATLABWindow_application
+# https://faq.i3wm.org/question/2564/cant-open-matlab-from-dmenu.1.html
+# https://wiki.archlinux.org/title/MATLAB#Desktop_entry
+# use /tmp as working (startup) directory and save simulink files there to avoid cross filesystem hardlink error:
+# https://bbs.archlinux.org/viewtopic.php?id=277970
+
+cmd () {
+	_JAVA_AWT_WM_NONREPARENTING=1 LD_PRELOAD=/lib64/libfreetype.so exec "$bin_dir/matlab" -sd "$startup_dir" -desktop -nosplash "$@"
+}
+
+startup_dir=/tmp/matlab
+bin_dir="$HOME/programs/MATLAB/R2022a/bin"
+addon_dir="$HOME/MATLAB Add-Ons"
+[ -d "$startup_dir" ] || mkdir "$startup_dir"
+
+# my workaround for simulink gyroscope compile errors: 
+# "avr-gcc: error: I2Cdev.o: No such file or directory" (also for other .o files)
+# "Code generation information file does not exist." (caused by no .o file error before I guess)
+# I guess it is still cross filesystem hardlink error
+# need to set path in matlab manually once for "$startup_dir/$addon_dir" sub dirs inside
+[ -d "$startup_dir/$addon_dir" ] || cp -r "$addon_dir" "$startup_dir"
+
+if ! cmd "$@"; then
+	"$bin_dir/activate_matlab.sh"
+	cmd "$@"
+fi