0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ubuntuでログイン時にアプリを自動起動する方法(GUI/CUI対応)

0
Posted at

はじめに

UbuntuでGUIユーザーとしてログイン時に、自動起動するアプリケーションを設定する方法を紹介する。

本記事で紹介する方法は「GUIログイン後」に実行される。
システム起動時(ログイン前)に実行したい場合は systemd など別の方法が必要なので注意。

動作確認環境

  • Ubuntu 22.04 x86_64 / arm64(aarch64)
    • GNOMEデスクトップ環境

方法

GUIとCUI、それぞれについて方法を説明する。

GUI

デスクトップ環境(設定画面)から設定する方法を説明する。

検索ウィンドウに「自動起動」を入力し、「自動起動するアプリケーションの設定」を開く。

image.png

image.png

「追加(A)」を押して、自動起動するアプリケーションを設定する。

image.png

CUI

Linuxでアプリケーションの起動方法を定義する設定ファイルである.desktopファイルを作成する。.desktopファイルExecには絶対パスを指定する必要があるので注意する。

以下のコマンドで~/.config/autostart/フォルダ内に、your-app-name.desktopファイルを作成する。

mkdir -p ~/.config/autostart
cd ~/.config/autostart
vi your-app-name.desktop

例1: Microsoft Teamsを自動起動する場合

teams.desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=Microsoft Teams - Preview
Exec=/usr/bin/teams %U
Icon=teams
Terminal=false
StartupNotify=false
Categories=Network;Application;
MimeType=x-scheme-handler/msteams;
X-GNOME-Autostart-enabled=true

例2: オリジナルのスクリプトを自動起動する場合 (your-script.sh)

オリジナルのスクリプトをyour-script.sh~/bin/your-script.shに保存して実行権限を以下のコマンドで付与しておく。

chmod +x ~/bin/your-script.sh

以下のyour-script.desktop~/.config/autostart内に作成する。

your-script.desktop
[Desktop Entry]
Type=Application
Exec=/home/username/bin/your-script.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[ja]=X Server Access
Name=X Server Access
Comment[ja]=
Comment=
  • username は自分のユーザー名に置き換える

まとめ

UbuntuでGUIユーザーとしてログイン時に、自動起動するアプリケーションを設定する方法を紹介した。組み込み機器などでアプリケーションを自動起動したい場合に有用なのでぜひ活用してほしい。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?