Skip to content

Instantly share code, notes, and snippets.

@Mossuru777
Created April 24, 2023 09:11
Show Gist options
  • Save Mossuru777/4d02cfa035d91b532528848a84867455 to your computer and use it in GitHub Desktop.
Save Mossuru777/4d02cfa035d91b532528848a84867455 to your computer and use it in GitHub Desktop.
タッチパッドでUbuntuのApplication LauncherをmacOSのジェスチャ風に表示したり消したりするやつ (Ubuntu 23.04 Wayland GNOME 44.0 で動作)

タッチパッドでUbuntuのApplication LauncherをmacOSのジェスチャ風に表示したり消したりするやつ

動くかもしれない環境

  • Wayland
  • GNOME 41 以上

動作した環境

    • Ubuntu 23.04
    • Wayland
    • GNOME 44.0

このgistの各ファイルの説明

  • setApplicationsViewStatus.sh
    Eval GJS GNOME Shell Extensionを利用して、Application Launcherをopen/closeするシェルスクリプト
    単体でsetApplicationsViewStatus.sh [open|close]として呼び出すこともできる

  • libinput-gestures.conf
    libinput-gesturesの設定ファイル
    指4本でpinch in/outしたときに、setApplicationsViewStatus.shを呼び出す内容
    setApplicationsViewStatus.shを$HOME/.local/setApplicationsViewStatus.shに配置する想定

導入手順

  1. libinput-gesturesをインストール
  2. Eval GJS GNOME Shell Extensionをインストール
    (READMEにも書いてあるが、GNOME 41からdbusでのEvalが制限されてしまったらしく、その回避策のパッケージ)
  3. setApplicationsViewStatus.shを$HOME/.local/setApplicationsViewStatus.shに配置し、ユーザーの実行権限を与える
  4. libinput-gestures.confを$HOME/.config/libinput-gestures.confとして配置もしくはこれを参考に作成する
  5. libinput-gesturesを起動している場合は設定ファイル読み込みのため、libinput-gestures stop startを実行する
# Configuration file for libinput-gestures.
# Mark Blakeney, Sep 2015
#
# The default configuration file exists at /etc/libinput-gestures.conf
# but a user can create a personal custom configuration file at
# ~/.config/libinput-gestures.conf.
#
# Lines starting with '#' and blank lines are ignored. Currently
# "gesture" and "device" configuration keywords are supported as
# described below. The keyword can optionally be appended with a ":" (to
# maintain compatibility with original format configuration files).
#
# Each gesture line has 3 [or 4] arguments separated by whitespace:
#
# action motion [finger_count] command
#
# where action and motion is either:
# swipe up
# swipe down
# swipe left
# swipe right
# swipe left_up
# swipe left_down
# swipe right_up
# swipe right_down
# pinch in
# pinch out
# pinch clockwise
# pinch anticlockwise
# hold on (hold gesture available since libinput 1.19)
#
# command is the remainder of the line and is any valid shell command +
# arguments. NOTE that the command is run directly and is not parsed by
# your shell. If you want shell parsing and substitutions etc then use a
# script as described in the CONFIGURATION section of the main README.
#
# finger_count is a single numeric digit and is optional (and is
# typically 3 or 4). If specified then the command is executed when
# exactly that number of fingers is used in the gesture. If not
# specified then the command is executed when that gesture is executed
# with any number of fingers. Gesture lines specified with finger_count
# have priority over the same gesture specified without any
# finger_count.
#
# Typically command will be _internal, or xdotool. See "man xdotool" for
# the many things you can action with that tool. Note that unfortunately
# xdotool does not work with native Wayland clients.
###############################################################################
# PINCH GESTURES:
###############################################################################
gesture pinch in 4 ~/.local/setApplicationsViewStatus.sh open
gesture pinch out 4 ~/.local/setApplicationsViewStatus.sh close
#!/bin/bash
if [[ $# -ne 1 ]] || { [[ "$1" != 'open' ]] && [[ "$1" != 'close' ]]; }; then
echo "illegal option.
Usage:
$0 [open|close]" >&2
exit 1
fi
# need install: https://github.com/ramottamado/eval-gjs
# ref: https://askubuntu.com/a/1349484
# ref: https://github.com/hardpixel/dash-to-plank/issues/12
# ref: https://github.com/hardpixel/dash-to-plank/commit/5b8ca9a545581df477ba93c0788dea6a41f3b0ea
dbus_eval_call() {
/usr/bin/gdbus call --session --dest org.gnome.Shell --object-path /dev/ramottamado/EvalGjs --method dev.ramottamado.EvalGjs.Eval "$1"
}
status=$(dbus_eval_call 'Main.overview.visible')
if [[ "$status" == "(true, 'false')" ]] && [[ "$1" == 'open' ]]; then
dbus_eval_call 'Main.overview.showApps()'
elif [[ "$status" == "(true, 'true')" ]] && [[ "$1" == 'close' ]]; then
dbus_eval_call 'Main.overview.hide()'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment