Last active
April 23, 2024 21:47
-
-
Save JSONOrona/aa9536df4169a585d5482d8131aab63e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Define user, groups, and background image path | |
user="savi" | |
groups="powerusers,wheel" # Groups to which the user will be added | |
background_image="/usr/share/backgrounds/background.bmp" # Path to the background image | |
# Check if user exists, if not create the user | |
if ! id "$user" &>/dev/null; then | |
echo "User $user does not exist. Creating user..." | |
sudo useradd -m "$user" | |
echo "User $user created." | |
fi | |
# Add user to necessary groups | |
for group in ${groups//,/ }; do | |
if grep -q "^$group:" /etc/group; then | |
echo "Adding $user to group $group." | |
sudo usermod -a -G "$group" "$user" | |
else | |
echo "Group $group does not exist. Creating group..." | |
sudo groupadd "$group" | |
sudo usermod -a -G "$group" "$user" | |
echo "Added $user to new group $group." | |
fi | |
done | |
# Create the kiosk directory and file if they do not exist | |
kiosk_dir="/etc/xdg/xfce4/kiosk" | |
kiosk_file="$kiosk_dir/kioskrc" | |
if [ ! -d "$kiosk_dir" ]; then | |
sudo mkdir -p "$kiosk_dir" | |
echo "Kiosk directory created." | |
fi | |
if [ ! -f "$kiosk_file" ]; then | |
sudo touch "$kiosk_file" | |
echo "Kiosk configuration file created." | |
fi | |
# Write kiosk mode settings into the kioskrc file | |
echo "Configuring kiosk mode..." | |
sudo bash -c "cat > $kiosk_file" <<EOF | |
[xfce4-panel] | |
CustomizePanel=%powerusers,$user | |
[xfce4-session] | |
CustomizeSplash=ALL | |
CustomizeChooser=ALL | |
CustomizeLogout=ALL | |
CustomizeCompatibility=%wheel | |
Shutdown=%wheel | |
CustomizeSecurity=NONE | |
[xfdesktop] | |
UserMenu=%wheel | |
CustomizeBackdrop=ALL | |
CustomizeDesktopMenu=%wheel | |
CustomizeWindowlist=NONE | |
CustomizeDesktopIcons=$user | |
EOF | |
echo "Kiosk mode configured successfully." | |
# Apply the background image to all workspaces on the primary monitor | |
echo "Setting background image..." | |
for workspace in {0..3}; do | |
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace${workspace}/last-image -s $background_image | |
done | |
echo "Background set for all workspaces on monitor0." | |
# Restart the XFCE panel to apply changes | |
xfce4-panel -r | |
echo "XFCE panel restarted. Configuration is now active." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if a username is provided | |
if [ -z "$1" ]; then | |
echo "Please provide a username as an argument." | |
exit 1 | |
fi | |
# Install required packages if they are not already installed | |
for package in xfce4 xfce4-terminal lightdm; do | |
if ! dpkg -l | grep -qw $package; then | |
sudo apt-get install -y $package | |
fi | |
done | |
# Wait for the user to log into XFCE before continuing | |
if [ "$2" != "configure" ]; then | |
echo "Please log into your XFCE session and then run this script again with the argument 'configure'" | |
exit 0 | |
fi | |
# Remove all existing XFCE panels | |
PANEL_IDS=$(xfconf-query -c xfce4-panel -p /panels -l | sed 's/\/panels\/panel-//') | |
for ID in $PANEL_IDS; do | |
xfconf-query -c xfce4-panel -p /panels/panel-$ID -rR | |
xfce4-panel -p /panels/panel-$ID --quit | |
done | |
xfce4-panel --restart | |
# Set desktop to show no icons if not already set | |
current_icons_setting=$(xfconf-query -c xfce4-desktop -p /desktop-icons/style) | |
if [ "$current_icons_setting" != "0" ]; then | |
xfconf-query -c xfce4-desktop -p /desktop-icons/style -n -t int -s 0 | |
fi | |
# Configure hotkeys for the terminal if not already set | |
if ! xfconf-query -c xfce4-keyboard-shortcuts -p "/commands/custom/<Primary><Alt>t"; then | |
xfconf-query -c xfce4-keyboard-shortcuts -p "/commands/custom/<Primary><Alt>t" -n -t string -s "xfce4-terminal" | |
fi | |
# Create a toggle script for minimal/full desktop | |
if ! [ -f ~/toggle_desktop.sh ]; then | |
cat <<EOF > ~/toggle_desktop.sh | |
#!/bin/bash | |
# Function to start extra components | |
start_full_desktop() { | |
xfconf-query -c xfwm4 -p /general/use_compositing -s true | |
xfce4-panel & | |
xfdesktop --reload | |
} | |
# Function to kill extra components | |
stop_full_desktop() { | |
killall xfce4-panel | |
xfdesktop --quit | |
xfconf-query -c xfwm4 -p /general/use_compositing -s false | |
} | |
# Check if the panel is running and toggle the state | |
if pgrep -x "xfce4-panel" > /dev/null; then | |
stop_full_desktop | |
else | |
start_full_desktop | |
fi | |
EOF | |
chmod +x ~/toggle_desktop.sh | |
fi | |
# Set desktop background image | |
background_image="/usr/share/backgrounds/background.bmp" | |
if [ -f "$background_image" ]; then | |
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s "$background_image" | |
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace1/last-image -s "$background_image" | |
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace2/last-image -s "$background_image" | |
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace3/last-image -s "$background_image" | |
else | |
echo "Background image not found. Please place your image in $background_image" | |
fi | |
# Configure LightDM for auto-login if not already set | |
auto_login_set=$(grep "autologin-user=" /etc/lightdm/lightdm.conf) | |
if [ -z "$auto_login_set" ]; then | |
echo "[Seat:*] | |
autologin-user=$1 | |
autologin-user-timeout=0" | sudo tee /etc/lightdm/lightdm.conf > /dev/null | |
fi | |
# Restart LightDM to apply changes if auto-login was just set | |
if [ -n "$auto_login_set" ]; then | |
sudo systemctl restart lightdm | |
fi | |
echo "Configuration complete! Restart your session for changes to take effect." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment