From 311ea5a00fd148936fb587df992cd1c030527a58 Mon Sep 17 00:00:00 2001 From: SeanChangX Date: Tue, 4 Mar 2025 02:31:49 +0800 Subject: [PATCH 1/3] Add desktop entries and scripts for launching DIT applications with tmux sessions --- desktop/DIT.desktop | 2 +- desktop/{localization.desktop => blue.desktop} | 4 ++-- desktop/yellow.desktop | 8 ++++++++ share/scripts/{localization.run => blue.run} | 0 share/scripts/{old => eurobot_2024}/ladybug.sh | 0 share/scripts/{old => eurobot_2024}/run.sh | 0 share/scripts/remove.sh | 10 ++++++++++ share/scripts/yellow.run | 10 ++++++++++ 8 files changed, 31 insertions(+), 3 deletions(-) rename desktop/{localization.desktop => blue.desktop} (56%) create mode 100755 desktop/yellow.desktop rename share/scripts/{localization.run => blue.run} (100%) rename share/scripts/{old => eurobot_2024}/ladybug.sh (100%) rename share/scripts/{old => eurobot_2024}/run.sh (100%) create mode 100755 share/scripts/yellow.run diff --git a/desktop/DIT.desktop b/desktop/DIT.desktop index 1b71861..b9e8c86 100755 --- a/desktop/DIT.desktop +++ b/desktop/DIT.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Type=Application Name=DIT Launcher -Exec=firefox http://localhost:5000 +Exec=firefox http://localhost:8080/?ds=foxglove-websocket&ds.url=ws://192.168.50.11:8765 Icon=/home/ditrobotics/DIT-Scripts/dit/DIT_logo.png Terminal=false Comment=Launch DIT script diff --git a/desktop/localization.desktop b/desktop/blue.desktop similarity index 56% rename from desktop/localization.desktop rename to desktop/blue.desktop index 4c55137..f69d1da 100755 --- a/desktop/localization.desktop +++ b/desktop/blue.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Type=Application -Name=Localization -Exec=/bin/bash -c "/home/share/scripts/localization.run" +Name=Blue +Exec=/bin/bash -c "/home/share/scripts/blue.run" Icon=utilities-terminal Terminal=true Comment=Launch DIT script diff --git a/desktop/yellow.desktop b/desktop/yellow.desktop new file mode 100755 index 0000000..03e2f5e --- /dev/null +++ b/desktop/yellow.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=Yellow +Exec=/bin/bash -c "/home/share/scripts/yellow.run" +Icon=utilities-terminal +Terminal=true +Comment=Launch DIT script + diff --git a/share/scripts/localization.run b/share/scripts/blue.run similarity index 100% rename from share/scripts/localization.run rename to share/scripts/blue.run diff --git a/share/scripts/old/ladybug.sh b/share/scripts/eurobot_2024/ladybug.sh similarity index 100% rename from share/scripts/old/ladybug.sh rename to share/scripts/eurobot_2024/ladybug.sh diff --git a/share/scripts/old/run.sh b/share/scripts/eurobot_2024/run.sh similarity index 100% rename from share/scripts/old/run.sh rename to share/scripts/eurobot_2024/run.sh diff --git a/share/scripts/remove.sh b/share/scripts/remove.sh index 0a16040..57f6b5d 100755 --- a/share/scripts/remove.sh +++ b/share/scripts/remove.sh @@ -1,5 +1,15 @@ #!/bin/bash +# Run a new session +tmux new-session -d -s eurobot-kill-script + +# Remove localization +tmux send-keys -t 0 "echo 'ditrobotics' | sudo -S docker compose -p communication -f /home/localization/Eurobot-2025-Localization/docker/testBot/OdomComm/docker/yellow-compose.yml down" C-m +tmux send-keys -t 0 "echo 'ditrobotics' | sudo -S docker compose -p communication -f /home/localization/Eurobot-2025-Localization/docker/testBot/OdomComm/docker/blue-compose.yml down" C-m + +# Attach to the session +tmux attach-session -d + # Delete the tmux session #tmux kill-session -t eurobot-script tmux kill-server diff --git a/share/scripts/yellow.run b/share/scripts/yellow.run new file mode 100755 index 0000000..88eea7b --- /dev/null +++ b/share/scripts/yellow.run @@ -0,0 +1,10 @@ +#!/bin/bash + +# Run a new session +tmux new-session -d -s eurobot-script + +# Run localization +tmux send-keys -t 0 "echo 'ditrobotics' | sudo -S docker compose -p communication -f /home/localization/Eurobot-2025-Localization/docker/testBot/OdomComm/docker/yellow-compose.yml up" C-m + +# Attach to the session +tmux attach-session -d From e1569d8c73fa349bed02b35e6ebce3013aba3fb7 Mon Sep 17 00:00:00 2001 From: SeanChangX Date: Fri, 14 Mar 2025 22:54:01 +0800 Subject: [PATCH 2/3] Refactor user preference restoration into separate script and add navigation launch script --- 00-pre-installation.sh | 18 +----- 15-user_preference.sh | 64 +++++++++++++++++++ desktop/nav.desktop | 8 +++ share/data/voltage.cache | 2 +- share/{ => eurobot_2024}/data/group.json | 0 share/{ => eurobot_2024}/data/score.cache | 0 share/{ => eurobot_2024}/data/state.json | 0 share/{ => eurobot_2024}/data/usb.json | 0 .../scripts}/ladybug.sh | 0 .../scripts}/run.sh | 0 share/scripts/nav.run | 10 +++ share/scripts/remove.sh | 2 + 12 files changed, 86 insertions(+), 18 deletions(-) create mode 100755 15-user_preference.sh create mode 100755 desktop/nav.desktop rename share/{ => eurobot_2024}/data/group.json (100%) rename share/{ => eurobot_2024}/data/score.cache (100%) rename share/{ => eurobot_2024}/data/state.json (100%) rename share/{ => eurobot_2024}/data/usb.json (100%) rename share/{scripts/eurobot_2024 => eurobot_2024/scripts}/ladybug.sh (100%) rename share/{scripts/eurobot_2024 => eurobot_2024/scripts}/run.sh (100%) create mode 100755 share/scripts/nav.run diff --git a/00-pre-installation.sh b/00-pre-installation.sh index 670319b..32c02f8 100755 --- a/00-pre-installation.sh +++ b/00-pre-installation.sh @@ -181,23 +181,7 @@ flip_screen() { # Restore user preference restore_user_preference() { - # Restore firefox configuration - echo -e "\033[32mRestoring firefox user preference...\033[0m" - # You need to open firefox first to create the folder - read -p "Please open firefox first. Press [Enter] key to continue..." - find /home/ditrobotics/snap/firefox/common/.mozilla/firefox/ -type d -name "*.default" -exec cp -r /home/ditrobotics/DIT-Scripts/.mozilla/firefox/dit_config.default/* {} \; - - # Restore desktop configuration - echo -e "\033[32mRestoring desktop user preference...\033[0m" - cp -r /home/ditrobotics/DIT-Scripts/desktop/* /home/ditrobotics/Desktop/ - - # Restore plymouth theme configuration - echo -e "\033[32mRestoring plymouth theme preference...\033[0m" - cp -r /home/ditrobotics/DIT-Scripts/system/plymouth-themes/abstract_ring_alt /usr/share/plymouth/themes/ - update-alternatives --install /usr/share/plymouth/themes/default.plymouth default.plymouth /usr/share/plymouth/themes/abstract_ring_alt/abstract_ring_alt.plymouth 100 - echo -e "\033[32mSelect the number for installed theme...\033[0m" - update-alternatives --config default.plymouth - update-initramfs -u + ./15-user_preference.sh sleep 1 progress_bar $step $total_steps diff --git a/15-user_preference.sh b/15-user_preference.sh new file mode 100755 index 0000000..d27af8d --- /dev/null +++ b/15-user_preference.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Check if the current user is root +if [ "$(id -u)" != "0" ]; then + echo -e "This script must be run as root. \nPlease run again with 'sudo $0'" + exit 1 +fi + +# Restore firefox configuration +restore_firefox() { + echo -e "\033[32mRestoring firefox user preference...\033[0m" + # You need to open firefox first to create the folder + read -p "Please open firefox first. Press [Enter] key to continue..." + find /home/ditrobotics/snap/firefox/common/.mozilla/firefox/ -type d -name "*.default" -exec cp -r /home/ditrobotics/DIT-Scripts/.mozilla/firefox/dit_config.default/* {} \; +} + +# Restore desktop configuration +restore_desktop() { + echo -e "\033[32mRestoring desktop user preference...\033[0m" + + cp -r /home/ditrobotics/DIT-Scripts/desktop/* /home/ditrobotics/Desktop/ + + if [ ! -d /home/share/scripts/ ]; then + mkdir -p /home/share/scripts/ + fi + cp -r /home/ditrobotics/DIT-Scripts/share/scripts/* /home/share/scripts/ + + if [ ! -d /home/share/data/ ]; then + mkdir -p /home/share/data/ + fi + cp -r /home/ditrobotics/DIT-Scripts/share/data/* /home/share/data/ +} + +# Restore plymouth theme configuration +restore_plymouth() { + echo -e "\033[32mRestoring plymouth theme preference...\033[0m" + cp -r /home/ditrobotics/DIT-Scripts/system/plymouth-themes/abstract_ring_alt /usr/share/plymouth/themes/ + update-alternatives --install /usr/share/plymouth/themes/default.plymouth default.plymouth /usr/share/plymouth/themes/abstract_ring_alt/abstract_ring_alt.plymouth 100 + echo -e "\033[32mSelect the number for installed theme...\033[0m" + update-alternatives --config default.plymouth + update-initramfs -u +} + +if [ "$1" == "all" ]; then + restore_firefox + restore_desktop + restore_plymouth +else + case "$1" in + firefox) + restore_firefox + ;; + desktop) + restore_desktop + ;; + plymouth) + restore_plymouth + ;; + *) + echo "Usage: $0 {all|firefox|desktop|plymouth}" + exit 1 + ;; + esac +fi diff --git a/desktop/nav.desktop b/desktop/nav.desktop new file mode 100755 index 0000000..9b72b31 --- /dev/null +++ b/desktop/nav.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=Navigation +Exec=/bin/bash -c "/home/share/scripts/nav.run" +Icon=utilities-terminal +Terminal=true +Comment=Launch DIT script + diff --git a/share/data/voltage.cache b/share/data/voltage.cache index 48eb703..ecba69c 100644 --- a/share/data/voltage.cache +++ b/share/data/voltage.cache @@ -1 +1 @@ -19.5 +00.0 diff --git a/share/data/group.json b/share/eurobot_2024/data/group.json similarity index 100% rename from share/data/group.json rename to share/eurobot_2024/data/group.json diff --git a/share/data/score.cache b/share/eurobot_2024/data/score.cache similarity index 100% rename from share/data/score.cache rename to share/eurobot_2024/data/score.cache diff --git a/share/data/state.json b/share/eurobot_2024/data/state.json similarity index 100% rename from share/data/state.json rename to share/eurobot_2024/data/state.json diff --git a/share/data/usb.json b/share/eurobot_2024/data/usb.json similarity index 100% rename from share/data/usb.json rename to share/eurobot_2024/data/usb.json diff --git a/share/scripts/eurobot_2024/ladybug.sh b/share/eurobot_2024/scripts/ladybug.sh similarity index 100% rename from share/scripts/eurobot_2024/ladybug.sh rename to share/eurobot_2024/scripts/ladybug.sh diff --git a/share/scripts/eurobot_2024/run.sh b/share/eurobot_2024/scripts/run.sh similarity index 100% rename from share/scripts/eurobot_2024/run.sh rename to share/eurobot_2024/scripts/run.sh diff --git a/share/scripts/nav.run b/share/scripts/nav.run new file mode 100755 index 0000000..ee96d4c --- /dev/null +++ b/share/scripts/nav.run @@ -0,0 +1,10 @@ +#!/bin/bash + +# Run a new session +tmux new-session -d -s eurobot-script-nav + +# Run navigation +tmux send-keys -t 0 "echo 'ditrobotics' | sudo -S docker compose -p navigation-run -f /home/navigation/Eurobot-2025-machine-ws/src/Eurobot-2025-Navigation2-envs/Navigation2-humble-deploy/docker-compose.yaml up" C-m + +# Attach to the session +tmux attach-session -d diff --git a/share/scripts/remove.sh b/share/scripts/remove.sh index 57f6b5d..1ff1079 100755 --- a/share/scripts/remove.sh +++ b/share/scripts/remove.sh @@ -6,6 +6,8 @@ tmux new-session -d -s eurobot-kill-script # Remove localization tmux send-keys -t 0 "echo 'ditrobotics' | sudo -S docker compose -p communication -f /home/localization/Eurobot-2025-Localization/docker/testBot/OdomComm/docker/yellow-compose.yml down" C-m tmux send-keys -t 0 "echo 'ditrobotics' | sudo -S docker compose -p communication -f /home/localization/Eurobot-2025-Localization/docker/testBot/OdomComm/docker/blue-compose.yml down" C-m +# Remove navigation +tmux send-keys -t 0 "echo 'ditrobotics' | sudo -S docker compose -p navigation-run -f /home/navigation/Eurobot-2025-machine-ws/src/Eurobot-2025-Navigation2-envs/Navigation2-humble-deploy/docker-compose.yaml down" C-m # Attach to the session tmux attach-session -d From 4211085da5a0decd5315926f991093de55178b2e Mon Sep 17 00:00:00 2001 From: SeanChangX Date: Fri, 14 Mar 2025 23:58:59 +0800 Subject: [PATCH 3/3] Update Conky configuration and enhance user preference restoration script --- .config/conky/conky-esp-config/.conky_esp32 | 9 +++++---- 00-pre-installation.sh | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.config/conky/conky-esp-config/.conky_esp32 b/.config/conky/conky-esp-config/.conky_esp32 index c1d0edf..0138a53 100644 --- a/.config/conky/conky-esp-config/.conky_esp32 +++ b/.config/conky/conky-esp-config/.conky_esp32 @@ -10,13 +10,13 @@ conky.config = { background = false, double_buffer = true, alignment = 'top_left', - gap_x = 300, - gap_y = 200, + gap_x = 680, + gap_y = 180, minimum_width = 200, minimum_height = 50, draw_outline = true, draw_borders = false, use_xft = true, - font = 'DejaVu Sans Mono:size=128', + font = 'Ubuntu Regular:size=28', default_color = 'white', default_outline_color = 'grey', default_shade_color = 'black', @@ -26,4 +26,5 @@ conky.config = { conky.text = [[ ${exec awk '{getline v < "/sys/class/power_supply/BAT0/voltage_now"; printf "%.1f W\n", v * $1 / 1000000000000}' /sys/class/power_supply/BAT0/current_now} ]]; --- ${execi 1 /home/ditrobotics/.config/conky/conky-esp-config/conky_esp32.sh} V \ No newline at end of file + +-- ${execi 1 /home/ditrobotics/.config/conky/conky-esp-config/conky_esp32.sh} V diff --git a/00-pre-installation.sh b/00-pre-installation.sh index 32c02f8..da0786e 100755 --- a/00-pre-installation.sh +++ b/00-pre-installation.sh @@ -181,7 +181,7 @@ flip_screen() { # Restore user preference restore_user_preference() { - ./15-user_preference.sh + ./15-user_preference.sh all sleep 1 progress_bar $step $total_steps