Skip to content

Commit

Permalink
Merge pull request #74 from dhruveshb-mecha/dev-v4
Browse files Browse the repository at this point in the history
feat: system config changes added
  • Loading branch information
dhruveshb-mecha authored Jan 4, 2025
2 parents 009b78d + 76f7c64 commit 9364aa7
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 29 deletions.
2 changes: 2 additions & 0 deletions debian/distro/build-debian.nu
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def main [machine: string, build_dir: string] {

configure_mecha_system_pref

configure_mecha_connect_desktop_file

set_config_dir_ownership

unmount_sys_proc_volumes
Expand Down
2 changes: 1 addition & 1 deletion debian/distro/conf-packages/target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ package_groups:
- dosfstools
- cpufrequtils
- upower
- libglib2.0-0-dbg
- libglib2.0-0
- name: network
packages:
- bluez
Expand Down
49 changes: 45 additions & 4 deletions debian/distro/modules/alacritty-config.nu
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,66 @@ export def configure_alacritty [] {
# Create config directory if it doesn't exist
if not ($config_dest | path exists) {
log_debug $"Creating directory: ($config_dest)"
SUDO mkdir -p $config_dest
mkdir $config_dest
}

# Copy configuration file
log_debug $"Copying ($alacritty_config) to ($config_dest)"
SUDO cp $alacritty_config $"($config_dest)/alacritty.yml"
cp $alacritty_config $"($config_dest)/alacritty.yml"
log_info "alacritty.yml copied successfully."

# Create theme directory and copy theme
log_info "Setting up Alacritty theme..."
if not ($theme_dest | path exists) {
log_debug $"Creating directory: ($theme_dest)"
SUDO mkdir -p $theme_dest
mkdir $theme_dest
}

# Copy theme file
log_debug $"Copying ($alacritty_theme) to ($theme_dest)"
SUDO cp $alacritty_theme $"($theme_dest)/flat-remix.yml"
cp $alacritty_theme $"($theme_dest)/flat-remix.yml"
log_info "flat-remix.yml theme file copied successfully."


# Create Alacritty.desktop file
let desktop_file_path = $rootfs_dir + "/usr/share/applications/Alacritty.desktop"
let desktop_file_dir = $rootfs_dir + "/usr/share/applications"

# Check if desktop entry exists and remove it
if ($desktop_file_path | path exists) {
log_debug $"Removing existing desktop entry: ($desktop_file_path)"
SUDO rm $desktop_file_path
}

let desktop_file_content = '[Desktop Entry]
Type=Application
TryExec=alacritty
Exec=alacritty
Icon=Alacritty
Terminal=false
Categories=System;TerminalEmulator;
Name=Alacritty
GenericName=Terminal
Comment=A fast, cross-platform, OpenGL terminal emulator
StartupNotify=true
StartupWMClass=Alacritty
Actions=New;
[Desktop Action New]
Name=New Terminal
Exec=alacritty
'

# Create desktop entry file
log_debug $"Writing desktop file to: ($desktop_file_path)"
# Write the content
echo $desktop_file_content | SUDO tee $desktop_file_path
# Set appropriate permissions
SUDO chmod 644 $desktop_file_path
log_debug "Desktop entry created successfully."



log_debug "Alacritty configuration completed successfully."
}
41 changes: 23 additions & 18 deletions debian/distro/modules/chromium-config.nu
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,36 @@ export def configure_chromium_preferences [] {


# Create chromium.desktop file
let desktop_file_path = "/usr/share/applications/chromium.desktop"
let desktop_file_dir = "/usr/share/applications"
let desktop_file_path = $rootfs_dir + "/usr/share/applications/chromium.desktop"
let desktop_file_dir = $rootfs_dir + "/usr/share/applications"

if not ($desktop_file_dir | path exists) {
log_debug $"Creating directory: ($desktop_file_dir)"
SUDO mkdir -p $desktop_file_dir
# Remove existing file if it exists
if ($desktop_file_path | path exists) {
log_debug $"Removing existing desktop file: ($desktop_file_path)"
SUDO rm $desktop_file_path
}

let desktop_file_content = '
[Desktop Entry]
Type=Application
TryExec=chromium
Exec=sh -c "export DISPLAY=:0 && chromium"
Icon=/usr/share/mechanix/shell/launcher/assets/icons/app_drawer/chromium_icon.png
Terminal=false
Categories=System;
Name=Chromium
GenericName=Chromium
Comment=Browser app
let desktop_file_content = '[Desktop Entry]
Type=Application
TryExec=chromium
Exec=sh -c "export DISPLAY=:0 && chromium"
Icon=/usr/share/mechanix/shell/launcher/assets/icons/app_drawer/chromium_icon.png
Terminal=false
Categories=System;
Name=Chromium
GenericName=Chromium
Comment=Browser app
'

# Create desktop entry file
log_debug $"Writing desktop file to: ($desktop_file_path)"
echo $desktop_file_content | SUDO tee $desktop_file_path
# Create empty file with sudo
SUDO touch $desktop_file_path
# Write the content
echo $desktop_file_content | SUDO tee $desktop_file_path out> /dev/null
# Set appropriate permissions
SUDO chmod 644 $desktop_file_path
log_debug "Desktop entry created successfully."


log_info "Chromium configuration completed."
Expand Down
60 changes: 54 additions & 6 deletions debian/distro/modules/system-config.nu
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export def configure_labwc_auto_launch [] {
# Create the config directory if it doesn't exist
if not ($config_dir | path exists) {
log_debug $"Creating directory: ($config_dir)"
SUDO mkdir -p $config_dir
mkdir $config_dir
}

# Define the autostart content
Expand Down Expand Up @@ -255,8 +255,7 @@ mechanix-keyboard -s /etc/mechanix/shell/keyboard/settings.yml &"
# Configure autostart file
if not ($autostart_file | path exists) {
log_debug $"Creating autostart file: ($autostart_file)"
echo $autostart_content | SUDO tee $autostart_file

echo $autostart_content | save $autostart_file
# Set proper permissions
SUDO chmod 644 $autostart_file
} else {
Expand All @@ -266,8 +265,7 @@ mechanix-keyboard -s /etc/mechanix/shell/keyboard/settings.yml &"
# Configure rc.xml file
if not ($rc_file | path exists) {
log_debug $"Creating rc.xml file: ($rc_file)"
echo $rc_content | SUDO tee $rc_file

echo $rc_content | save $rc_file
# Set proper permissions
SUDO chmod 644 $rc_file
} else {
Expand All @@ -291,6 +289,14 @@ export def set_config_dir_ownership [] {
} catch {
|error| log_error $"Failed to set ownership : ($error)"
}

# set permissions to 700
try {
CHROOT chmod 700 $config_dir
log_info "Permissions set successfully."
} catch {
|error| log_error $"Failed to set permissions : ($error)"
}
}

export def configure_mecha_system_pref [] {
Expand All @@ -315,7 +321,8 @@ export def configure_mecha_system_pref [] {
"/usr/share/applications/system-config-printer.desktop",
"/usr/share/applications/vim.desktop",
"/usr/share/applications/debian-uxterm.desktop",
"/usr/share/applications/debian-xterm.desktop"
"/usr/share/applications/debian-xterm.desktop",
"/usr/share/applications/mecha-connect.desktop",
]

for file in $files_to_remove {
Expand All @@ -329,4 +336,45 @@ for file in $files_to_remove {
}

log_info "System-wide settings configuration completed."
}


export def configure_mecha_connect_desktop_file [] {
log_info "Configuring Mecha Connect desktop entry:"
let rootfs_dir = $env.ROOTFS_DIR

# Create mecha-connect.desktop file
let desktop_file_path = $rootfs_dir + "/usr/share/applications/org.mecha.connect.desktop"
let desktop_file_dir = $rootfs_dir + "/usr/share/applications"

# Remove existing file if it exists
if ($desktop_file_path | path exists) {
log_debug $"Removing existing desktop file: ($desktop_file_path)"
SUDO rm $desktop_file_path
}

let desktop_file_content = '[Desktop Entry]
Type=Application
TryExec=mecha-connect
Exec=mecha-connect
Icon=/usr/share/mechanix/shell/launcher/assets/icons/app_drawer/mecha_connect_icon.png
Terminal=false
Categories=System;
Name=Connect
GenericName=Connect
Comment=Connect app
'

# Create desktop entry file
log_debug $"Writing desktop file to: ($desktop_file_path)"
# Create empty file with sudo
SUDO touch $desktop_file_path
# Write the content
echo $desktop_file_content | SUDO tee $desktop_file_path out> /dev/null
# Set appropriate permissions
SUDO chmod 644 $desktop_file_path
log_debug "Desktop entry created successfully."

log_info "Mecha Connect desktop configuration completed."
}

0 comments on commit 9364aa7

Please sign in to comment.