# [TUT] How to remove whole desktop enviroments with single command



## ayleid96 (Jan 8, 2022)

Many people always ask these kinds of questions, but here is the command replace *mate-* word with xfce-,kde- etc..:

```
pkg delete `pkg info -q | grep mate-`
```

Note that KDE packages names contain "plasma5", so run this command with *plasma5-* after you ran *kde-.*

So to break it down, *pkg-info* works with installed packages, while *pkg-search* works with packages in repo. By combining the output of *pkg-info* with* pkg-delete* we can achieve this.


----------



## jbo (Jan 8, 2022)

ayleid96 said:


> `pkg delete `pkg info -q | grep mate``


This is just asking for trouble.
Unless I'm missing something this is happily gonna remove non-related packages that just happen to have `mate` in their name. Example: audio/checkmate.


----------



## jmos (Jan 8, 2022)

Beside the already said (at least you've got to check the output of the query command before executing) the de-installation is incomplete: You need also a `pkg autoremove` afterwards to get rid of many, many packages that are installed as a dependency of those packages…


----------



## ayleid96 (Jan 8, 2022)

jbodenmann said:


> This is just asking for trouble.
> Unless I'm missing something this is happily gonna remove non-related packages that just happen to have `mate` in their name. Example: audio/checkmate.


That is not big issue, just add -, mate-, kde-, plasma5-, xfce4-


----------



## ayleid96 (Jan 8, 2022)

Anyway i think pkg needs to consider package grouping. To solve these problems especially.


----------



## jmos (Jan 8, 2022)

No. There's a package "x11/mate" - if you install it, it raises alll other packages as dependencies. Just deinstall it, and a `pkg autoremove` removes all related packages. Same for other DEs.

BTW: www/nginx-ultimate-bad-bot-blocker; Just adding "-" won't solve the problem. The problem: Unchecked strings instead of parsing dependencies.


----------



## jbo (Jan 8, 2022)

ayleid96 said:


> Anyway i think pkg needs to consider package grouping. To solve these problems especially.


What exactly is the problem to be solved by pkg(7) if I may ask?
Unless I misunderstand your intentions you can either install a metaport like jmos mentioned, then remote the port and run `pkg autoremove` and you're done. If you need more granular control about the installed packages which prevents you from using the metaport a certain level of knowledge is implicitly attached to that (otherwise you will most likely not encounter that situation) and then you'd also know that your proposed solution has the aforementioned problem.
Other than that, you can always create your own metaport package and just remove that.

On top of that: What exactly is the usecase for "completely removing whole desktop environments" anyway? That's not a re-occurring task, right?
If you just want to test a new DE and get rid of it afterwards you can create a filesystem snapshot, install the new package, tinker around, then roll back. Alternatively create a clone from the snapshot or any of the other possible solutions (or just a speparate jail / VM which can be removed easily).


----------



## grahamperrin@ (Jan 8, 2022)

ayleid96 said:


> … package grouping. …



FreshPorts is our friend.

For _kde5_ (not to be confused with the desktop environment) we have <https://www.freshports.org/x11/kde5/#dependencies>:

*a group of eleven* _runtime_ dependencies
one of which is the FreeBSD _meta port_ for KDE Plasma – Plasma is _a desktop_.


When someone installs kde5 on FreeBSD, they'll get that group of eleven; plus whatever is required by each of the eleven.

plasma5-plasma, the meta port, naturally has *larger groups* of dependencies: <https://www.freshports.org/x11/plasma5-plasma/#dependencies>.


----------



## grahamperrin@ (Jan 9, 2022)

Above, I reworded things slightly, to more accurately include the phrase _meta port_.


What's below is slightly mind-bending.

x11/plasma5-plasma is:

the meta port for KDE Plasma.
KDE Plasma is:

a desktop.
x11/plasma5-plasma-desktop is:

the `plasma5` Plasma desktop
required by x11/plasma5-plasma – <https://www.freshports.org/x11/plasma5-plasma-desktop/#requiredforBuild>
I wondered *which one* of those two ports is definitely Plasma (the desktop).

I guess:

*both* are KDE Plasma
the meta port is intended for use cases that require KDE Plasma _alone_
– x11/plasma5-plasma-workspace, which provides essentials such as /usr/local/bin/plasmashell, is a requirement of both plasma5-plasma and plasma5-plasma-desktop; and so on.


If you use Plasma but don't yet know the significance of `plasmashell`, you can safely:

`krunner`
`pkill plasmashell & plasmashell`


----------



## shkhln (Jan 9, 2022)

ayleid96 said:


> ```
> pkg delete `pkg info -q | grep mate-`
> ```


`pkg remove 'mate-*'`


----------



## bsduck (Jan 9, 2022)

grahamperrin said:


> What's below is slightly mind-bending.


I agree, the whole thing is quite confusing.


----------



## grahamperrin@ (Jan 9, 2022)

bsduck said:


> … the whole thing is quite confusing.



*Configuration options* might help to distinguish between the meta port and plasma5-plasma-desktop. Respectively: 


```
===> The following configuration options are available for plasma5-plasma-5.23.2:
     PHONON=on: Include phonon-gstreamer, for sound output
     PULSEAUDIO=on: PulseAudio sound server support
===> Use 'make config' to modify these settings
```

the norm
please, no multi-paragraph knee-jerks about PulseAudio – instead, you can edit one line in one file


```
===> The following configuration options are available for plasma5-plasma-desktop-5.23.5:
====> Input Method Support
     IBUS=off: Enable IBUS backend for input dialog
     SCIM=off: Enable SCIM backend for input dialog
===> Use 'make config' to modify these settings
```

this port might be preferred by someone who doesn't need the GStreamer backend for Phonon, or its plugins.


----------



## grahamperrin@ (Jan 9, 2022)

> `pkg remove 'mate-*'`



I could do, but then any one of the three deleted packages that I want to reinstall – none of which has the phrase _mate_ in its name – leads to reinstallation of things such as x11/mate-desktop, and so on, so I prefer to simply keep x11/mate without the rigmarole below.



Spoiler: Multiple reinstallations following a single run of pkg remove 'mate-*'





```
root@mowa219-gjp4-8570p-freebsd:~ # pkg remove --yes 'mate-*'
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 29 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        atril: 1.26.0_3
        caja: 1.26.0_1
        caja-extensions: 1.26.0
        engrampa: 1.26.0
        eom: 1.26.0
        mate: 1.26.0
        mate-applets: 1.26.0
        mate-backgrounds: 1.26.0
        mate-base: 1.26.0
        mate-calc: 1.26.0
        mate-control-center: 1.26.0
        mate-desktop: 1.26.0
        mate-icon-theme: 1.26.0
        mate-indicator-applet: 1.26.0
        mate-media: 1.26.0
        mate-menus: 1.26.0
        mate-notification-daemon: 1.26.0
        mate-panel: 1.26.1,1
        mate-polkit: 1.26.0
        mate-power-manager: 1.26.0
        mate-screensaver: 1.26.1_1
        mate-session-manager: 1.26.0
        mate-settings-daemon: 1.26.0
        mate-system-monitor: 1.26.0
        mate-terminal: 1.26.0
        mate-themes: 3.22.23
        mate-user-guide: 1.26.0
        mate-utils: 1.26.0
        mozo: 1.26.1

Number of packages to be removed: 29

The operation will free 429 MiB.
[1/29] Deinstalling mate-1.26.0...
[2/29] Deinstalling mate-base-1.26.0...
[3/29] Deinstalling mate-indicator-applet-1.26.0...
[3/29] Deleting files for mate-indicator-applet-1.26.0: 100%
[4/29] Deinstalling mate-applets-1.26.0...
[4/29] Deleting files for mate-applets-1.26.0: 100%
[5/29] Deinstalling mate-control-center-1.26.0...
[5/29] Deleting files for mate-control-center-1.26.0: 100%
[6/29] Deinstalling mate-media-1.26.0...
[6/29] Deleting files for mate-media-1.26.0: 100%
[7/29] Deinstalling mate-notification-daemon-1.26.0...
[7/29] Deleting files for mate-notification-daemon-1.26.0: 100%
[8/29] Deinstalling mate-power-manager-1.26.0...
[8/29] Deleting files for mate-power-manager-1.26.0: 100%
[9/29] Deinstalling mate-screensaver-1.26.1_1...
[9/29] Deleting files for mate-screensaver-1.26.1_1: 100%
[10/29] Deinstalling mate-utils-1.26.0...
[10/29] Deleting files for mate-utils-1.26.0: 100%
[11/29] Deinstalling atril-1.26.0_3...
[11/29] Deleting files for atril-1.26.0_3: 100%
[12/29] Deinstalling caja-extensions-1.26.0...
[12/29] Deleting files for caja-extensions-1.26.0: 100%
[13/29] Deinstalling mozo-1.26.1...
[13/29] Deleting files for mozo-1.26.1: 100%
[14/29] Deinstalling engrampa-1.26.0...
[14/29] Deleting files for engrampa-1.26.0: 100%
[15/29] Deinstalling mate-panel-1.26.1,1...
[15/29] Deleting files for mate-panel-1.26.1,1: 100%
[16/29] Deinstalling mate-session-manager-1.26.0...
[16/29] Deleting files for mate-session-manager-1.26.0: 100%
[17/29] Deinstalling mate-settings-daemon-1.26.0...
[17/29] Deleting files for mate-settings-daemon-1.26.0: 100%
[18/29] Deinstalling mate-system-monitor-1.26.0...
[18/29] Deleting files for mate-system-monitor-1.26.0: 100%
[19/29] Deinstalling caja-1.26.0_1...
[19/29] Deleting files for caja-1.26.0_1: 100%
[20/29] Deinstalling eom-1.26.0...
[20/29] Deleting files for eom-1.26.0: 100%
[21/29] Deinstalling mate-backgrounds-1.26.0...
[21/29] Deleting files for mate-backgrounds-1.26.0: 100%
[22/29] Deinstalling mate-calc-1.26.0...
[22/29] Deleting files for mate-calc-1.26.0: 100%
[23/29] Deinstalling mate-desktop-1.26.0...
[23/29] Deleting files for mate-desktop-1.26.0: 100%
[24/29] Deinstalling mate-icon-theme-1.26.0...
[24/29] Deleting files for mate-icon-theme-1.26.0: 100%
[25/29] Deinstalling mate-menus-1.26.0...
[25/29] Deleting files for mate-menus-1.26.0: 100%
[26/29] Deinstalling mate-polkit-1.26.0...
[26/29] Deleting files for mate-polkit-1.26.0: 100%
[27/29] Deinstalling mate-terminal-1.26.0...
[27/29] Deleting files for mate-terminal-1.26.0: 100%
[28/29] Deinstalling mate-themes-3.22.23...
[28/29] Deleting files for mate-themes-3.22.23: 100%
[29/29] Deinstalling mate-user-guide-1.26.0...
[29/29] Deleting files for mate-user-guide-1.26.0: 100%
Building the Shared MIME-Info database cache
Building cache database of MIME types
Generating GTK icon cache for /usr/local/share/icons/hicolor
root@mowa219-gjp4-8570p-freebsd:~ # pkg install caja eom mozo
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating poudriere repository catalogue...
poudriere repository is up to date.
All repositories are up to date.
The following 7 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        caja: 1.26.0_1 [FreeBSD]
        eom: 1.26.0 [FreeBSD]
        mate-desktop: 1.26.0 [FreeBSD]
        mate-icon-theme: 1.26.0 [FreeBSD]
        mate-menus: 1.26.0 [FreeBSD]
        mate-panel: 1.26.1,1 [FreeBSD]
        mozo: 1.26.1 [FreeBSD]

Number of packages to be installed: 7

The process will require 74 MiB more space.
21 MiB to be downloaded.

Proceed with this action? [y/N]: n
root@mowa219-gjp4-8570p-freebsd:~ # pkg install -n caja
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating poudriere repository catalogue...
poudriere repository is up to date.
All repositories are up to date.
The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        caja: 1.26.0_1 [FreeBSD]
        mate-desktop: 1.26.0 [FreeBSD]
        mate-icon-theme: 1.26.0 [FreeBSD]

Number of packages to be installed: 3

The process will require 50 MiB more space.
17 MiB to be downloaded.
root@mowa219-gjp4-8570p-freebsd:~ # pkg install -n eom
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating poudriere repository catalogue...
poudriere repository is up to date.
All repositories are up to date.
The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        eom: 1.26.0 [FreeBSD]
        mate-desktop: 1.26.0 [FreeBSD]
        mate-icon-theme: 1.26.0 [FreeBSD]

Number of packages to be installed: 3

The process will require 42 MiB more space.
16 MiB to be downloaded.
root@mowa219-gjp4-8570p-freebsd:~ # pkg install -n mozo
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating poudriere repository catalogue...
poudriere repository is up to date.
All repositories are up to date.
The following 4 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        mate-desktop: 1.26.0 [FreeBSD]
        mate-menus: 1.26.0 [FreeBSD]
        mate-panel: 1.26.1,1 [FreeBSD]
        mozo: 1.26.1 [FreeBSD]

Number of packages to be installed: 4

The process will require 19 MiB more space.
3 MiB to be downloaded.
root@mowa219-gjp4-8570p-freebsd:~ # time pkg install --quiet --yes mate
Building the Shared MIME-Info database cache
Building cache database of MIME types
Generating GTK icon cache for /usr/local/share/icons/mate
Generating GTK icon cache for /usr/local/share/icons/menta
Generating GTK icon cache for /usr/local/share/icons/ContrastHigh
Generating GTK icon cache for /usr/local/share/icons/hicolor
Generating GTK icon cache for /usr/local/share/icons/mate-black
=====
Message from mate-base-1.26.0:

--
Congratulations!  MATE base has been successfully installed on your system.
For help on starting it up, as well as answers to common questions, and
some known issues, please see the FreeBSD GNOME homepage at:

                       http://www.FreeBSD.org/gnome/
=====
Message from mate-1.26.0:

--
Congratulations!  MATE base has been successfully installed on your system.
For help on starting it up, as well as answers to common questions, and
some known issues, please see the FreeBSD GNOME homepage at:

                       http://www.FreeBSD.org/gnome/
19.093u 9.417s 4:47.19 9.9%     2273+498k 25403+95139io 638pf+0w
root@mowa219-gjp4-8570p-freebsd:~ # pkg autoremove
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages:

Installed packages to be REMOVED:
        libindicator: 12.10.1

Number of packages to be removed: 1

Proceed with deinstalling packages? [y/N]: n
root@mowa219-gjp4-8570p-freebsd:~ # pkg iinfo -ix caja eom mozo
caja-1.26.0_1
caja-extensions-1.26.0
eom-1.26.0
lib2geom-1.1
mozo-1.26.1
root@mowa219-gjp4-8570p-freebsd:~ #
root@mowa219-gjp4-8570p-freebsd:~ # pkg info -x mate-indicator-applet
pkg: No package(s) matching mate-indicator-applet
root@mowa219-gjp4-8570p-freebsd:~ # pkg install mate-indicator-applet
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating poudriere repository catalogue...
poudriere repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        mate-indicator-applet: 1.26.0 [FreeBSD]

Number of packages to be installed: 1

98 KiB to be downloaded.

Proceed with this action? [y/N]: y
[1/1] Fetching mate-indicator-applet-1.26.0.pkg: 100%   98 KiB 100.5kB/s    00:01   
Checking integrity... done (0 conflicting)
[1/1] Installing mate-indicator-applet-1.26.0...
[1/1] Extracting mate-indicator-applet-1.26.0: 100%
Generating GTK icon cache for /usr/local/share/icons/hicolor
root@mowa219-gjp4-8570p-freebsd:~ # pkg autoremove
Checking integrity... done (0 conflicting)
Nothing to do.
root@mowa219-gjp4-8570p-freebsd:~ #
```


----------



## ayleid96 (Jan 9, 2022)

I see your arguments, and i agree. If you think that this is unsafe or non-convenient way to managing things, remove this post.


----------



## grahamperrin@ (Jan 10, 2022)

Oh, it's not a bad thing to have people experiment and share ideas. Everybody learns. Discussion here revealed what might be a bug in the port of MATE, and so on. 

If you like, maybe edit the title: 



> [TUT] How to remove whole desktop enviroments with single command



– as things turned out, it's more like discussion of: 



> Desktop environment packaging and removal



(Not exactly a tutorial.)

Thanks


----------



## jmos (Jan 10, 2022)

ayleid96 said:


> If you think that this is unsafe or non-convenient way to managing things, remove this post.


No need to remove this post - we just do it right  The correct way to install and remove a desktop environment with one command:

*Install*
A desktop environment normally has a so called "meta port"; Such a port doesn't contain software, but dependencies to the needed packages. F.e. a `pkg install mate` will install all packages for the MATE desktop.

*Remove*
Just deinstall the the meta port, and afterwards its dependencies. In one go for the MATE desktop example:
`pkg delete mate && pkg autoremove`

You will be asked if it's okay to remove a bunch of packages - read it before saying "yes" (because sometimes it includes a packages that you want to keep). A `pkg autoremove` will only give you a good result if you took care about what's manually, and what's automatically installed. Installing the meta port instead of single packages ensures this.


----------



## grahamperrin@ (Jan 10, 2022)

jmos said:


> … packages for the MATE desktop. …



A question for users of MATE. Do you think of the *indicator applet* as part of MATE? 

Its description (with added emphasis):



> The indicator applet exposes Ayatana Indicators in the MATE Panel. Ayatana Indicators are an initiative by Canonical to provide crisp and clean system and application status indication. They take the form of an icon and associated menu, displayed (usually) in the desktop panel. Existing indicators include the *Message Menu, Battery Menu and Sound menu*.


----------

