Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug session for debugging with existing cosmic install #1108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ifneq ($(VENDOR),0)
endif

TARGET_BIN="$(DESTDIR)$(bindir)/$(BINARY)"
DEBUG_TARGET_BIN="$(DESTDIR)$(bindir)/debug-$(BINARY)"

KEYBINDINGS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicSettings.Shortcuts/v1/defaults"
TILING_EXCEPTIONS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicSettings.WindowRules/v1/tiling_exception_defaults"
Expand Down Expand Up @@ -59,8 +60,24 @@ install-bare-session: install
install -Dm0644 "data/cosmic-comp.service" "$(DESTDIR)$(libdir)/systemd/user/cosmic-comp.service"
install -Dm0755 "data/cosmic-service" "$(DESTDIR)/$(bindir)/cosmic-service"

install-debug:
install -Dm0755 "$(CARGO_TARGET_DIR)/$(TARGET)/$(BINARY)" "$(DEBUG_TARGET_BIN)"

install-debug-session: install-debug
install -Dm0644 "debug-data/debug-cosmic.desktop" "$(DESTDIR)$(sharedir)/wayland-sessions/debug-cosmic.desktop"
install -Dm0644 "debug-data/debug-cosmic-comp.service" "$(DESTDIR)$(libdir)/systemd/user/debug-cosmic-comp.service"
install -Dm0755 "debug-data/debug-cosmic-service" "$(DESTDIR)/$(bindir)/debug-cosmic-service"

uninstall:
rm "$(TARGET_BIN)" "$(KEYBINDINGS_CONF)"

uninstall-bare-session:
rm "$(DESTDIR)$(sharedir)/wayland-sessions/cosmic.desktop"

uninstall-debug:
rm "$(DEBUG_TARGET_BIN)"

uninstall-debug-session:
rm "$(DESTDIR)$(sharedir)/wayland-sessions/cosmic.desktop"
rm "$(DESTDIR)$(libdir)/systemd/user/debug-cosmic-comp.service"
rm "$(DESTDIR)/$(bindir)/debug-cosmic-service"
12 changes: 12 additions & 0 deletions debug-data/debug-cosmic-comp.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Debug Cosmic wayland compositor
BindsTo=cosmic-session.target
Wants=cosmic-session-pre.target
After=cosmic-session-pre.target
Before=cosmic-session.target

[Service]
Type=notify
ExecStart=/usr/bin/debug-cosmic-comp
Restart=never
ExecStopPost=/usr/bin/systemctl --user unset-environment DISPLAY WAYLAND_DISPLAY
52 changes: 52 additions & 0 deletions debug-data/debug-cosmic-service
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

set -e

# From: https://people.debian.org/~mpitt/systemd.conf-2016-graphical-session.pdf

if command -v systemctl >/dev/null; then
# robustness: if the previous graphical session left some failed units,
# reset them so that they don't break this startup
for unit in $(systemctl --user --no-legend --state=failed --plain list-units | cut -f1 -d' '); do
partof="$(systemctl --user show -p PartOf --value "$unit")"
for target in cosmic-session.target graphical-session.target; do
if [ "$partof" = "$target" ]; then
systemctl --user reset-failed "$unit"
break
fi
done
done
fi

# use the user's preferred shell to acquire environment variables
# see: https://github.com/pop-os/cosmic-session/issues/23
if [ -n "${SHELL}" ]; then
# --in-login-shell: our flag to indicate that we don't need to recurse any further
if [ "${1}" != "--in-login-shell" ]; then
# `exec -l`: like `login`, prefixes $SHELL with a hyphen to start a login shell
exec bash -c "exec -l '${SHELL}' -c '${0} --in-login-shell'"
fi
fi

export XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:=COSMIC}"
export XDG_SESSION_TYPE="${XDG_SESSION_TYPE:=wayland}"
export XCURSOR_THEME="${XCURSOR_THEME:=Cosmic}"
export _JAVA_AWT_WM_NONREPARENTING=1
export GDK_BACKEND=wayland,x11
export MOZ_ENABLE_WAYLAND=1
export QT_QPA_PLATFORM="wayland;xcb"
export QT_AUTO_SCREEN_SCALE_FACTOR=1
export QT_ENABLE_HIGHDPI_SCALING=1
export DCONF_PROFILE=cosmic
export RUST_LOG=debug

if command -v systemctl >/dev/null; then
# set environment variables for new units started by user service manager
systemctl --user import-environment XDG_SESSION_TYPE XDG_CURRENT_DESKTOP
fi
# Run cosmic-session
if [[ -z "${DBUS_SESSION_BUS_ADDRESS}" ]]; then
exec /usr/bin/dbus-run-session -- /usr/bin/cosmic-session /usr/bin/debug-cosmic-comp
else
exec /usr/bin/cosmic-session /usr/bin/debug-cosmic-comp
fi
7 changes: 7 additions & 0 deletions debug-data/debug-cosmic.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Desktop Entry]
Name=Debug Cosmic
Commment=This session logs you into Cosmic
Exec=/usr/bin/debug-cosmic-service
Type=Application
DesktopNames=pop:COSMIC
X-GDM-SessionRegisters=false
95 changes: 95 additions & 0 deletions debug-data/keybindings.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
(modifiers: [Super, Shift], key: "Escape"): Terminate,
(modifiers: [Super, Ctrl], key: "Escape"): Debug,
(modifiers: [Super], key: "Escape"): System(LockScreen),
(modifiers: [Super], key: "q"): Close,

(modifiers: [Super], key: "1"): Workspace(1),
(modifiers: [Super], key: "2"): Workspace(2),
(modifiers: [Super], key: "3"): Workspace(3),
(modifiers: [Super], key: "4"): Workspace(4),
(modifiers: [Super], key: "5"): Workspace(5),
(modifiers: [Super], key: "6"): Workspace(6),
(modifiers: [Super], key: "7"): Workspace(7),
(modifiers: [Super], key: "8"): Workspace(8),
(modifiers: [Super], key: "9"): Workspace(9),
(modifiers: [Super], key: "0"): LastWorkspace,
(modifiers: [Super, Shift], key: "1"): MoveToWorkspace(1),
(modifiers: [Super, Shift], key: "2"): MoveToWorkspace(2),
(modifiers: [Super, Shift], key: "3"): MoveToWorkspace(3),
(modifiers: [Super, Shift], key: "4"): MoveToWorkspace(4),
(modifiers: [Super, Shift], key: "5"): MoveToWorkspace(5),
(modifiers: [Super, Shift], key: "6"): MoveToWorkspace(6),
(modifiers: [Super, Shift], key: "7"): MoveToWorkspace(7),
(modifiers: [Super, Shift], key: "8"): MoveToWorkspace(8),
(modifiers: [Super, Shift], key: "9"): MoveToWorkspace(9),
(modifiers: [Super, Shift], key: "0"): MoveToLastWorkspace,

(modifiers: [Super, Ctrl, Alt], key: "Left"): MoveToOutput(Left),
(modifiers: [Super, Ctrl, Alt], key: "Down"): MoveToOutput(Down),
(modifiers: [Super, Ctrl, Alt], key: "Up"): MoveToOutput(Up),
(modifiers: [Super, Ctrl, Alt], key: "Right"): MoveToOutput(Right),
(modifiers: [Super, Ctrl, Alt], key: "h"): MoveToOutput(Left),
(modifiers: [Super, Ctrl, Alt], key: "k"): MoveToOutput(Down),
(modifiers: [Super, Ctrl, Alt], key: "j"): MoveToOutput(Up),
(modifiers: [Super, Ctrl, Alt], key: "l"): MoveToOutput(Right),

(modifiers: [Super], key: "Period"): NextOutput,
(modifiers: [Super], key: "Comma"): PreviousOutput,
(modifiers: [Super, Shift], key: "Period"): MoveToNextOutput,
(modifiers: [Super, Shift], key: "Comma"): MoveToPreviousOutput,

(modifiers: [Super], key: "Left"): Focus(Left),
(modifiers: [Super], key: "Right"): Focus(Right),
(modifiers: [Super], key: "Up"): Focus(Up),
(modifiers: [Super], key: "Down"): Focus(Down),
(modifiers: [Super], key: "h"): Focus(Left),
(modifiers: [Super], key: "j"): Focus(Down),
(modifiers: [Super], key: "k"): Focus(Up),
(modifiers: [Super], key: "l"): Focus(Right),
(modifiers: [Super], key: "u"): Focus(Out),
(modifiers: [Super], key: "i"): Focus(In),

(modifiers: [Super, Shift], key: "Left"): Move(Left),
(modifiers: [Super, Shift], key: "Right"): Move(Right),
(modifiers: [Super, Shift], key: "Up"): Move(Up),
(modifiers: [Super, Shift], key: "Down"): Move(Down),
(modifiers: [Super, Shift], key: "h"): Move(Left),
(modifiers: [Super, Shift], key: "j"): Move(Down),
(modifiers: [Super, Shift], key: "k"): Move(Up),
(modifiers: [Super, Shift], key: "l"): Move(Right),

(modifiers: [Super], key: "o"): ToggleOrientation,
(modifiers: [Super], key: "s"): ToggleStacking,
(modifiers: [Super], key: "y"): ToggleTiling,
(modifiers: [Super], key: "g"): ToggleWindowFloating,
(modifiers: [Super], key: "x"): SwapWindow,

(modifiers: [Super], key: "m"): Maximize,
(modifiers: [Super], key: "r"): Resizing(Outwards),
(modifiers: [Super, Shift], key: "r"): Resizing(Inwards),

(modifiers: [Super], key: "b"): System(WebBrowser),
(modifiers: [Super], key: "f"): System(HomeFolder),
(modifiers: [Super], key: "t"): System(Terminal),

(modifiers: [Super], key: "a"): System(AppLibrary),
(modifiers: [Super], key: "w"): System(WorkspaceOverview),
(modifiers: [Super], key: "slash"): System(Launcher),
(modifiers: [Super]): System(Launcher),
(modifiers: [Alt], key: "Tab"): System(WindowSwitcher),
(modifiers: [Alt, Shift], key: "Tab"): System(WindowSwitcherPrevious),
(modifiers: [Super], key: "Tab"): System(WindowSwitcher),
(modifiers: [Super, Shift], key: "Tab"): System(WindowSwitcherPrevious),

(modifiers: [], key: "Print"): System(Screenshot),
(modifiers: [], key: "XF86AudioRaiseVolume"): System(VolumeRaise),
(modifiers: [], key: "XF86AudioLowerVolume"): System(VolumeLower),
(modifiers: [], key: "XF86AudioMute"): System(Mute),
(modifiers: [], key: "XF86AudioMicMute"): System(MuteMic),
(modifiers: [], key: "XF86MonBrightnessUp"): System(BrightnessUp),
(modifiers: [], key: "XF86MonBrightnessDown"): System(BrightnessDown),
(modifiers: [], key: "XF86AudioPlay"): System(PlayPause),
(modifiers: [], key: "XF86AudioPrev"): System(PlayPrev),
(modifiers: [], key: "XF86AudioNext"): System(PlayNext),
}
50 changes: 50 additions & 0 deletions debug-data/tiling-exceptions.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[
// Any appid title only matching
(
appid: ".*",
titles: [
"Discord Updater",
]
),
// Empty appid title only matches
(
appid: "",
titles: [
"Steam",
"wl-clipboard",
]
),


// Appid matches
(appid: "Authy Desktop", titles: [".*"]),
(appid: "Com.github.amezin.ddterm", titles: [".*"]),
(appid: "Com.github.donadigo.eddy", titles: [".*"]),
(appid: "com.system76.CosmicFilesDialog", titles: [".*"]),
(appid: "Enpass", titles: ["Enpass Assistant"]),
(appid: "Gjs", titles: ["Settings"]),
(appid: "Gnome-initial-setup", titles: [".*"]),
(appid: "Gnome-terminal", titles: ["Preferences - General"]),
(appid: "Guake", titles: [".*"]),
(appid: "Io.elementary.sideload", titles: [".*"]),
(appid: "KotatogramDesktop", titles: ["Media viewer"]),
(appid: "Mozilla VPN", titles: [".*"]),
(appid: "update-manager", titles: ["Software Updater"]),
(appid: "Solaar", titles: [".*"]),
(appid: "Steam", titles: ["^.*?(Guard|Login).*"]),
(appid: "TelegramDesktop", titles: ["Media viewer"]),
(appid: "Zotero", titles: ["Quick Format Citation"]),
(appid: "gjs", titles: [".*"]),
(appid: "gnome-screenshot", titles: [".*"]),
(appid: "ibus-.*", titles: [".*"]),
(appid: "jetbrains-toolbox", titles: [".*"]),
(appid: "jetbrains-webstorm", titles: ["Customize WebStorm", "License Activation", "Welcome to WebStorm"]),
(appid: "krunner", titles: [".*"]),
(appid: "pritunl", titles: [".*"]),
(appid: "re.sonny.Junction", titles: [".*"]),
(appid: "system76-driver", titles: [".*"]),
(appid: "tilda", titles: [".*"]),
(appid: "zoom", titles: [".*"]),
(appid: "^.*?action=join.*$", titles: [".*"]),

]