Linux Mint 18.3 LXDE

Forum rules
Before you post please read how to get help
Post Reply
User avatar
kneekoo
Level 2
Level 2
Posts: 74
Joined: Tue Nov 06, 2007 2:38 pm
Location: Stuttgart, Germany
Contact:

Linux Mint 18.3 LXDE

Post by kneekoo » Fri Dec 29, 2017 8:02 pm

Hey everyone!

I made a script to easily setup an LXDE flavor of Linux Mint for my 1GB RAM netbook. I installed Linux Mint 18.3 Xfce 32-bit, I ran the script and LXDE is there in all its glory, on top of the familiar Linux Mint.

Now this is merely an experiment at this stage. I refrained going into heavy customizations or anything - my goal was to replace Xfce with LXDE. If the script gets enough interest we might find solutions to "mintify" the LXDE experience in a more significant manner. Take a look at the video, check my script, play with it in a virtual machine or some old netbook, and tell me how it feels. :) Considering the script is very basic, I expect nothing else but a rock-solid working environment as long as you start from scratch with Xfce, as I did.

The script: http://www.linuxmint.ro/lxde

The one-line command to replace Xfce with LXDE:

Code: Select all

curl -sAFirefox www.linuxmint.ro/lxde | bash
The video demonstration:
https://youtu.be/VSbY_B-vTec

Have fun! :)

P.S. Added right-click "Open in Terminal", and "Open as Root" in the file manager.
Image
Come visit PHP-Fusion Romania

User avatar
Pjotr
Level 20
Level 20
Posts: 10973
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Re: Linux Mint 18.3 LXDE

Post by Pjotr » Tue Jan 02, 2018 10:06 am

Looks good! :)

How does it compare to the German inofficial LXDE spin of Mint 18.3?
https://www.linuxmintusers.de/index.php?topic=45551.0
Tip: 10 things to do after installing Linux Mint 19 Tara
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

User avatar
kneekoo
Level 2
Level 2
Posts: 74
Joined: Tue Nov 06, 2007 2:38 pm
Location: Stuttgart, Germany
Contact:

Re: Linux Mint 18.3 LXDE

Post by kneekoo » Tue Jan 02, 2018 3:52 pm

Thanks for pointing out that release. I have no idea what's different but I'll try it and make an opinion. For now, what I can tell for sure is the fact that my script produces a simple Linux Mint LXDE desktop, but it's based on an official image.
Image
Come visit PHP-Fusion Romania

User avatar
Termy
Level 5
Level 5
Posts: 762
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Linux Mint 18.3 LXDE

Post by Termy » Fri Jan 05, 2018 6:57 am

Here are some changes you'd maybe want to consider:

Code: Select all

#!/bin/bash

[ $UID -eq 0 ] || { printf "ERROR: Root access is required.\n"; exit 1; }

printf -v LOG "%s/%(%F-%H%M%S)T" "$HOME" "-1"
DETAILS="You will find details about the error in: $LOG"
LXDESKTOP="/etc/xdg/lxsession/LXDE/desktop.conf"
PCMANFM="/etc/xdg/pcmanfm/LXDE/pcmanfm.conf"

timeStamp () { printf "%(%F-%T)T :: %s\n" "-1" "$1" | tee -a "$LOG"; }
logThis () { printf "%s\n" "$1" | tee -a "$LOG"; }

timeStamp "Step 1/3 > Updating the APT cache..."
if ! apt-get update &>> "$LOG"; then
    logThis "ERROR: Update failed ($?)"
    logThis "Please make sure you have a working internet connection and a fresh Linux Mint 18#
    printf "%s\n" "$DETAILS"
    exit 1
fi

timeStamp "Step 1/3 > Updating the APT cache..."
if ! apt-get update &>> "$LOG"; then
    logThis "ERROR: Update failed ($?)"
    logThis "Please make sure you have a working internet connection and a fresh Linux Mint 18#
    printf "%s\n" "$DETAILS"
    exit 1
fi

timeStamp "Step 2/3 > Installing LXDE..."
apt-get -y install pavucontrol lxde lxsession-logout lxtask &>> "$LOG"

timeStamp "Step 3/3 > Uninstalling Xfce..."
if ! apt-get -y purge thunar* xfce* xfdesktop4-data xfwm4 xfconf xviewer &>> "$LOG"; then
    logThis "ERROR: The Xfce removal ran into an error"
    printf "%s\n" "$DETAILS"
fi

sed -i -e 's/ThemeName=.*/ThemeName=Mint-X/g'\
       -e 's/IconThemeName=.*/IconThemeName=Mint-X/g' "$LXDESKTOP"
sed -i -e 's/wallpaper_mode=.*/wallpaper_mode=crop/g'\
       -e 's/wallpaper=.*/wallpaper=\/usr\/share\/backgrounds\/linuxmint\/default_background.j#

ACTIONS="/usr/local/share/file-manager/actions"
mkdir -p "$ACTIONS"

OPENASROOT="$ACTIONS/openasroot.desktop"
{
        while read -r; do
                printf "%s\n" "$REPLY"
        done <<-ASROOT
                [Desktop Entry]
                Type=Action
                Name=Open as Root
                Icon=seahorse-preferences
                Profiles=openasroot;
                
                [X-Action-Profile openasroot]
                Exec=gksu pcmanfm %f
                Name=Default profile
        ASROOT
} > "$OPENASROOT"

OPENINTERM="$ACTIONS/openinterm.desktop"
{
        while read -r; do
                printf "%s\n" "$REPLY"
        done <<-INTERM
                [Desktop Entry]
                Type=Action
                Name=Open in Terminal
                Icon=terminal
                Profiles=openinterm;
                
                [X-Action-Profile openinterm]
                Exec=lxterminal %f
                Name=Default profile
        INTERM
} > "$OPENINTERM"

service lightdm restart
Mostly just simplifies, improves, or fixes some bits. You'll wanna run it first though, as I don't have the time to do any testing.

You might already know all of this, but just in-case: there's a clash of opinions when it comes to having sudo within scripts. Some say never do it, some say it doesn't matter. I avoid it unless I need it, personally. You can always run commands as a regular user within the script, if there is something sensitive going on.
Here to help.

I'm LearnLinux (LL) on YouTube: https://www.youtube.com/channel/UCfp-lN ... naEE6NtDSg
I'm also terminalforlife (TFL) on GitHub: https://github.com/terminalforlife

User avatar
kneekoo
Level 2
Level 2
Posts: 74
Joined: Tue Nov 06, 2007 2:38 pm
Location: Stuttgart, Germany
Contact:

Re: Linux Mint 18.3 LXDE

Post by kneekoo » Sun Jan 07, 2018 4:27 am

Thanks for your suggestions, Termy. I surely appreciate more advanced takes on bash scripting, as I'm still learning. :) I would appreciate if you would give me a few details about your changes - for instance why "$LOG" instead of plain $LOG. (well, I found this specific thing :P)

But your "simplified" script is 10 lines longer and more cryptic. I must point out that I made the script in a way that's slightly easier to read and comprehend by less experienced users. The easier it is for people to understand what it does, the higher the chances they can trust it only does good things. There are way too much security issues around, and mistrust, so I would make it even more readable if it's possible.

And I thought about checking the super user rights but I gave up on that because I preferred sudo to ask for the password. This way we wouldn't have to run the script again, with sudo. Then to get rid of the sudo in front of all the lines I could've done a self-call with sudo $0 if the script isn't run as root, but although it's less elegant as it is, it's more readable for the common user and I decided to leave it like that. Can you spot something else that can be made more readable?

Cheers! o/
Image
Come visit PHP-Fusion Romania

User avatar
Termy
Level 5
Level 5
Posts: 762
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Linux Mint 18.3 LXDE

Post by Termy » Fri Jan 12, 2018 6:24 pm

Sorry, I forgot about this thread. :?

"$LOG" is out of habit; it's good practice to, where valid, surround variable calls in quotation marks, to protect what's assigned from being interpreted by the shell.

Fair enough on the simplicity aspect. I didn't realise you were intentionally shooting for that. I'm stuck in my ways; I write the code for the result which is for the user, rather than the code for the user. I've also been doing this for a little while and gotten so stuck into it that I forget how dizzying it used to look. I can definitely appreciate the mistrust thing as well. Maybe I should consider simplifying my code, but then why hamper my code because of some rotten eggs spoiling it for the rest of us? Aaaah, ... xD To be fair, if you don't understand the code and/or don't trust it, then it's not for you, generally speaking; I don't mean you, personally. I bet C++ programmers aren't trying to make sure their programs are simple enough for everybody to understand. :P

More lines don't necessarily mean it's worse off. A short version can be just as bad as a long version. Depends on what's used, how, and why. Too many approaches to things to be concrete about any of it, but my approach, personally, tends to be to use as few a number of processes as possible, to concerve resources and boost portability; it's a habit. Why bring in all these other programs if the shell itself can do it? More often than not, it can. Unless speed is required, of course. :P

There's a debate that seems everlasting about whether you should or shouldn't have sudo in a script. I avoid it, unless needed. I prefer, and feel it's better presented, to use sudo on the command line, like all the other programs. As long as you write the code carefully (or use sudo -u user to reduce privileges with sensitive commands) you can limit the risks. Using sudo $0 would need to be done with care, lest you wind up with two separate instances of the script, which could clash.
Here to help.

I'm LearnLinux (LL) on YouTube: https://www.youtube.com/channel/UCfp-lN ... naEE6NtDSg
I'm also terminalforlife (TFL) on GitHub: https://github.com/terminalforlife

User avatar
kneekoo
Level 2
Level 2
Posts: 74
Joined: Tue Nov 06, 2007 2:38 pm
Location: Stuttgart, Germany
Contact:

Re: Linux Mint 18.3 LXDE

Post by kneekoo » Fri Jan 12, 2018 10:42 pm

Indeed, I could use a lock file for sudo $0 to make sure there's only one instance of the script running. But it looks like going downhill with checking the super user rights. :P At least here I can rely on APT to deny running multiple operations, so no damage would be done with multiple instances of the script.

I don't know a thing about the supposedly everlasting debate on sudo in scripts but normally I am against it too. In this case it's just practical. Even if it helps one person I'm happy - it means I succeeded in making it readable to someone. :mrgreen:
Image
Come visit PHP-Fusion Romania

Post Reply

Return to “Scripts & Bash”