Start applications in linux

Ubuntu Documentation

Move your mouse pointer to the Activities corner at the top left of the screen to show the Activities overview. This is where you can find all of your applications. You can also open the overview by pressing the Super key.

There are several ways of opening an application once you’re in the Activities overview:

Start typing the name of an application — searching begins instantly. (If this doesn’t happen, click the search bar at the top of the screen and start typing.) If you don’t know the exact name of an application, try to type an related term. Click the application’s icon to start it.

Some applications have icons in the dash , the vertical strip of icons on the left-hand side of the Activities overview. Click one of these to start the corresponding application.

If you have applications that you use very frequently, you can add them to the dash yourself.

Click the grid button at the bottom of the dash. You will see the frequently used applications if the Frequent view is enabled. If you want to run a new application, press the All button at the bottom to view all the applications. Press on the application to start it.

You can launch an application in a separate workspace by dragging its icon from the dash, and dropping it onto one of the workspaces on the right-hand side of the screen. The application will open in the chosen workspace.

You can launch an application in a new workspace by dragging its icon to the empty workspace at the bottom of the workspace switcher, or to the small gap between two workspaces.

Quickly running a command

Another way of launching an application is to press Alt + F2 , enter its command name , and then press the Enter key.

For example, to launch Rhythmbox , press Alt + F2 and type ‘ rhythmbox ’ (without the single-quotes). The name of the app is the command to launch the program.

Use the arrow keys to quickly access previously run commands.

Источник

How to Autorun Application at the Start up in Linux

Contents

Introduction

This article describes how to automatically start an application during or after boot of an Apalis, Colibri and Verdin Computer on Modules running Embedded Linux.

TorizonCore

On TorizonCore, the applications are packaged in containers. The containers are run by the container engine, which is Docker in our case.

Docker is already set to autorun, and to start your applications on boot in TorizonCore you must describe what containers to use and how to bring them up. Please have a look at our content about the steps to automatically start a container with TorizonCore in Run and Manage Docker Containers on Torizon.

Reference Images for Yocto Project

For our Reference Images for Yocto Project, you can follow any of the topics described below in order to attend to your project or use-case needs.

Systemd

Starting with V2.x of our Linux BSP we use systemd as our init and service manager.

Systemd is a system and service manager for Linux, also capable of replacing the traditional SysV init system. You can read its manual here.

A unit configuration is a file which name ends in .service, and it encodes information about a process controlled and supervised by systemd. Service files can be found in /etc/systemd/system/ and, for distribution provided ones in /lib/systemd/system/ .

You can enable, disable, start, stop and check services status by using the systemctl command.

The common configuration items are configured in the generic [Unit] and [Install] sections.

Читайте также:  1c mac os nodename nor servname provided

The service specific configuration options are configured in the [Service] section.

Service files must include a [Service] section, which carries information about the service and the process it supervises.

For more information possible options of a [Service] section refer to the documentation.

Procedure

Create a unit configuration file ending in .service

Copy the unit configuration file to /etc/systemd/system and use the systemctl tool for enabling and starting the service.

Using the systemctl command

Based on the SystemD documentation, you need to reload the systemd configuration after the addition or change on any unit files:

To check a service status, or to start and stop a service, which is valid until next reboot, you can use the following commands:

To add a service to or remove it from the list of services to be started at boot. Note: This neither starts or stops the service but takes only effect during the next boot

Here is an example of an unit configuration file to automatically execute the (hypothetical) mydatalogger application at start up:

Shells

/etc/profile

Each time a login shell is spawned, the script /etc/profile plus all scripts in /etc/profile.d are executed.

This is done for logins over a serial console, over an ssh connection and also for logins in the display manager to a graphical desktop.

/etc/profile is sourced upon login: it sets up the environment upon login and application-specific settings by sourcing any readable file in /etc/profile.d/ .

Using /etc/profile is well suited to set the environment or to do some small tasks.

Note that these scripts must return control in order to continue with the login.

Remove the file in /etc/profile.d or the additions to /etc/profile in order to undo the automatic execution.

Procedure

To load a Shell Script at each login, you just need to add a script file in /etc/profile.d/ .

Remembering that the Shell Script must have the *.sh extension.

Below is an example of a script file for deleting backup entries:

Graphical

Weston Desktop

The more recent Toradex Linux BSP 5 has been using the Weston/Wayland graphic compositor, instead of the X11 that has been used until our BSP 3.0.

Please be aware that Wayland is the Protocol, Weston is the Graphical Compositor which implements the Wayland protocol. You can read more about it at Wayland page.

Any graphical application developed for X11 should work as well, as the Weston compositor is configured to operate with the XWayleand compatibility mode, which allows X11 Clients.

That said, for you to create a graphical application that will automatically start with the system boot, this application must start after Weston service.

An example for a wayland graphical application to be automatically executed on boot is presented below.

As you can see, that service calls a script to be executed. That’s because it’s necessary to check if the XDG_RUNTIME_DIR environment variable has been set, and if not, we must set it.

Weston will use XDG_RUNTIME_DIR for Window Context.

It’s also recommended to export the DISPLAY variable accordingly as well. See below:

With both the service and the script, your Wayland application will be automatically executed on boot.

Yocto Project/OpenEmbedded

We prepared scripts to autorun your application in Wayland/Weston on startup directly from a Yocto Project/OpenEmbedded build. It is called wayland-app-launch and also how we autorun Qt Demos on the Multimedia Reference Image. Check out the given links, which contain examples of how you can integrate this into OE.

X11 Desktop

You can start applications automatically when you login into your Window Manager or Desktop Environment.

With the angstrom-lxde-image you’ll get the following options. Other desktop environments provide similar means.

The lxsession session manager can start applications when the graphical environment is started.

This can be achieved in two ways:

A lxsession specific way, in which the entries in the files /etc/xdg/lxsession/LXDE/autostart and

/.config/lxsession/LXDE/autostart are parsed.

A generic way which many session managers support. Files in the folders /etc/xdg/autostart/ and

/.config/autostart/ ending with .desktop get parsed and, if applicable, the application described therein is started.

You can check more information in the LXSession documentation.

LXSession Autostart File

To use the 1st option, you will need to edit /etc/xdg/lxsession/LXDE/autostart or

Add the application or command-line you want to be executed to a new line in the file.

Читайте также:  Кнопки для быстрого запуска приложений операционной системы windows расположены

If you want that your application be restarted if it gets terminated abnormally, precede the application name with a @. Like for example the lxterminal, with @lxterminal at /etc/xdg/lxsession/LXDE/autostart:

Note that this file is not a shell script and therefore shell acrobatics like redirections and pipes are not allowed.

If required this can done by spawning a custom shell script, which in turn can support the full shell feature set.

.desktop Files

Basically, to have a service or application to start with this approach, the steps are to create a .desktop file and add it to autostart.

You can check more information about this in the .desktop file documentation. Note: In /usr/share/applications/ there is already a number of .desktop files which can be copied into the autostart folder.

For example, if you want to execute lxterminal automatically at startup, you can do the following: 1. Create a terminal.desktop in /etc/xdg/autostart/ . Add some key entries like:

  • [Desktop Entry] — Must be the first line of every desktop file and is the section header to identify the block of key value pairs associated with the desktop. Necessary for the desktop to recognize the file correctly.
  • Name of the application.(The name of the Desktop Entry group — should be unique on the system )
  • Type of the application. (Possible values are «Application», «Link» or «Directory».)
  • Exec filename of the application plus optionally arguments.
  • Terminal (Describes whether the application should run in a terminal.)

An example of a .desktop file content with the entries should be as follows:

  1. After editing, save the .desktop.

Note: A graphical file manager will list .desktop files not with their file name but rather with the value of the key «Name». e.g. in the example above «LXTerminal».

To disable the automatic start of an application, just either remove the respective *.desktop file from /etc/xdg/autostart/ and/or .config/autostart/ , or add the key NotShowIn=LXDE; to the desktop file.

Alternatively use the graphical front end ‘LXDE Menu’/Preferences/’Desktop Session Settings’ and untik the ‘Enabled’ checkbox.

X11 with One User Application

If your use-case requires to start X11, probably it will also require to start some configuration tasks like keyboard mapping, touch screen calibration and then start the one and only user application. In this case, you can adopt a scheme like the one used in angstrom-qt5-x11-image and qt4e-demo-image.

Script Started by Systemd

The qt4e-demo-image and angstrom-qt5-x11-image (prior to 2.8b2) use a systemd service and a home brew script. The script starts the X-server followed by the user application. Integrating any setup tasks between the start of X11 and the start of the user application into the script produces a bunch of issues as this sometimes stops the X-server and so on.

However for a simple system that might be enough.

To start your X11 application instead of the demo application change the script accordingly.

Using nodm, xinit, and a Custom Script

The angstrom-qt5-x11-image (starting with 2.8b2) uses the simple display manager nodm from OpenEmbedded to start X11. This uses the configuration data in /etc/X11 , e.g. Xsession.d, e.g. to start the touch calibrator. As the last step it searches for a script x-window-manager and sources that one.

To start your X11 application override the following two variables in the x-window-simple-app recipe to set the initial working directory and to specify the application:

Источник

Start and stop application from terminal in Linux Mint 19 / Ubuntu 18.04

In this article we will review several scenarios how to :

  • Start application from terminal — Ubuntu / Linux Mint
  • Schedule application start
  • Build script starting application
  • Stop application by id/name in Linux Mint / Ubuntu
  • Application stop with delay
  • Auto logout from Ubuntu / Linux Mint
  • Bonus tip: schedule application stop

Start application from terminal — Ubuntu / Linux Mint

In order to start application from terminal you need to know the name of the application which is used in the system. Sometimes the system name can differ from the application name. For example:

  • Chrome — google-chrome
  • Chromium — chromium-browser
  • Sublime — subl

You can find where a given application is installed by:

Also there you can search for applications.

In order to start give application you need to write it’s name in the terminal:

You can pass different parameters to the application which will be opened. For example which file to be opened for Libre office:

Читайте также:  Kmsauto lite как пользоваться windows

or what web sites to be opened with chrome:

Schedule application start

Sometimes you may want to schedule a script for opening a given application. In order to improve my performance and decrease the distractions I’m scheduling my mail to be opened two times per day: 10:00 and 16:00.

The scheduling in Linux usually is done with cron jobs:

  • Open terminal
  • Type: crontab -e — for current user only or sudo crontab -e
  • finally add your job:

Some application can be started by their name but others will need some settings. For example in order to start thunderbird and display it you need to add this line in your crontab file:

the same way if you are using bash script to start another application. For example starting LibreOffice calc:

where libre office will be started after a csv file with data is downloaded from a website.(I’ll add new article on this topic).

Build script starting application

Building special scripts to start application can be helpful in order to automate boring stuff. I have 10 scripts which are helping me to do boring stuff like:

  • reporting
  • getting information from the web
  • sending mails
  • analysing data
  • starting and stoping application — obviously from the article 🙂

Below you can find several examples below:

  • the first row is going to «log» each time this scripted is executed
  • the second one is opening thunderbird

A more complex example where:

this example is more complex. Here is what is done:

  • activate special python virtual environment
  • change to a special folder
  • run a web spider in order to get information from Google
  • analyze and change the data
  • load the download data in calc

this script is run with a cron job every day and retrieves important information for me. If I need to do the same thing I’ll need to spend 10 to 30 minutes per day.

Stop application by id/name

To stop application from the terminal by id you will need to find the id first. This can be done by this command:

10882 10869 10831 10784 10781

Another alternative is:

10882 10869 10831 10784 10781

or the more verbose one:

user 2315 0.0 0.0 15648 1152 pts/1 S+ 18:38 0:00 grep —color=auto google-chrome
user 10781 0.3 0.4 1379564 151624 ? SLl 14:57 0:47 /usr/lib/..

and then you can extract the pid-s.

After that in order to stop the application you can use:

both do similar things but the one with -9 is more «aggressive» and forcing.

In order to stop/kill application by name you can use:

this is going to kill multiple processes by name.

Application stop with delay

Now let say that you want to stop a given application with some delay: 10 minutes, 1 hour or something else. You can do with by several different ways: cron job, script, third party software. In this case we will use simple script:

this script will wait for 1 hour and then will stop the application. So you can use a script to start a given application. This application to be executed for 1 hour and finally to be stopped.

Other times examples:

Note: You can’t use:

Auto logout from Ubuntu / Linux Mint

The final problem which we are going to cover in the article is about log out of inactive users. There is application for Ubuntu / Linux Mint which can be used — autolog. You can search in the software center and install it. Or you can install it by:

Bonus tip: schedule application stop

Let say that you work a lot google chrome, slack, zoom, pycharm or any other application in Linux Mint, Ubuntu. Most of the time is really difficult to end up your working day and leave your workplace. Automation to the rescue! Below you can find a simple script and how to use in order to schedule stop for your applications in Linux:

The script will show the current date and time. Then will wait for a given period of time ( in this case 30 minutes ) and finally will kill the application.

now you can schedule this script as a cronjob by:

Источник

Оцените статью