From 9584de22d8f8410f5bf3b39396767855094f88b9 Mon Sep 17 00:00:00 2001 From: Wryn Wagner Date: Wed, 24 Feb 2021 13:32:04 -0700 Subject: [PATCH] Fixed scratchpad launcher utils --- bin/desktop/i3/launch-or-show-application.sh | 12 +++++++++++ config/i3/config | 22 +++++++------------- config/i3/utils | 13 ++++++++++++ 3 files changed, 32 insertions(+), 15 deletions(-) create mode 100755 bin/desktop/i3/launch-or-show-application.sh diff --git a/bin/desktop/i3/launch-or-show-application.sh b/bin/desktop/i3/launch-or-show-application.sh new file mode 100755 index 0000000..558d3d7 --- /dev/null +++ b/bin/desktop/i3/launch-or-show-application.sh @@ -0,0 +1,12 @@ +CLIENT_CLASS="$1" +APPLICATION="$2" + +echo "client class:'$CLIENT_CLASS'" +echo "application :'$APPLICATION'" + +xdotool search --class "$CLIENT_CLASS" >/dev/null 2>&1 || { + i3-msg "exec --no-startup-id $APPLICATION;" +} + +i3-msg "[class=$CLIENT_CLASS] move scratchpad"; +i3-msg "[class=$CLIENT_CLASS] scratchpad show"; diff --git a/config/i3/config b/config/i3/config index 14b7ccc..1aa125b 100644 --- a/config/i3/config +++ b/config/i3/config @@ -12,10 +12,9 @@ set $UTILS /home/w0ryn/.config/wryn/i3utils set $SLACK_CLIENT_CLASS ^Slack$ set $MESSAGE_CLIENT_CLASS ^android-messages-desktop$ -set $MEDIA_CLIENT_CLASS ^youtubemusic-nativefier-.*$ +set $MEDIA_CLIENT_CLASS ^youtubemusic-nativefier set $DISCORD_CLIENT_CLASS ^discord$ - -set $EMAIL_CLIENT_INSTANCE ^Mail$ +set $EMAIL_CLIENT_CLASS ^Thunderbird$ set $GAMES_CLIENT_CLASSES ^(Steam)|(dolphin-emu)|(Visualboyadvance-m)$ set $TERMINAL_EMULATOR_CLASSES ^(kitty)$ @@ -101,19 +100,12 @@ floating_modifier $mod bindsym $mod+Shift+Tab move scratchpad bindsym $mod+Tab scratchpad show -bindsym $mod+Shift+d [class=$DISCORD_CLIENT_CLASS] scratchpad show -for_window [class=$DISCORD_CLIENT_CLASS] move scratchpad +bindsym $mod+Shift+d exec --no-startup-id $UTILS discord $DISCORD_CLIENT_CLASS; +bindsym $mod+Shift+t exec --no-startup-id $UTILS email $EMAIL_CLIENT_CLASS; +bindsym $mod+m exec --no-startup-id $UTILS media $MEDIA_CLIENT_CLASS; +bindsym $mod+Shift+m exec --no-startup-id $UTILS message $MESSAGE_CLIENT_CLASS; +bindsym $mod+Shift+s exec --no-startup-id $UTILS slack $SLACK_CLIENT_CLASS; -bindsym $mod+Shift+m [class=$MESSAGE_CLIENT_CLASS] scratchpad show -for_window [class=$MESSAGE_CLIENT_CLASS] move scratchpad - -bindsym $mod+Shift+t [instance=$EMAIL_CLIENT_INSTANCE] scratchpad show -for_window [instance=$EMAIL_CLIENT_INSTANCE] move scratchpad - -bindsym $mod+m [class=$MEDIA_CLIENT_CLASS] scratchpad show -for_window [class=$MEDIA_CLIENT_CLASS] move scratchpad; [class=$MEDIA_CLIENT_CLASS] scratchpad show - -bindsym $mod+Shift+s [class=$SLACK_CLIENT_CLASS] scratchpad show bindsym $mod+Shift+x [class=$GAMES_CLIENT_CLASSES] scratchpad show bindsym $mod+x [class=$TERMINAL_EMULATOR_CLASSES] scratchpad show diff --git a/config/i3/utils b/config/i3/utils index 75b90ac..0c58892 100755 --- a/config/i3/utils +++ b/config/i3/utils @@ -1,6 +1,7 @@ #!/bin/sh UTIL_BIN="$HOME/.wryn/bin/desktop" +APP_BIN="$HOME/.config/wryn/default-applications" MEDIA__NEXT="$UTIL_BIN/youtube-music/next.sh" MEDIA__PREV="$UTIL_BIN/youtube-music/previous.sh" @@ -16,11 +17,17 @@ BACKLIGHT__DOWN="$UTIL_BIN/xbacklight/down.sh"; LOCK_SCREEN="$UTIL_BIN/i3lock/lock.sh"; LOG_OUT="$UTIL_BIN/i3/logout.sh"; +LAUNCH_OR_SHOW="$UTIL_BIN/i3/launch-or-show-application.sh"; BG_RANDOMIZE="$UTIL_BIN/feh/randomize-background.sh" ALTERNATE_TERMINAL="$UTIL_BIN/kitty/alternate-terminal.sh" +DISCORD="$APP_BIN/discord" +EMAIL="$APP_BIN/email" +MEDIA="$APP_BIN/media" +MESSAGES="$APP_BIN/messages" +SLACK="$APP_BIN/slack" case $1 in next ) "$MEDIA__NEXT" ;; @@ -41,4 +48,10 @@ case $1 in bgrandomize ) "$BG_RANDOMIZE" ;; alternateterm ) "$ALTERNATE_TERMINAL" ;; + + discord ) "$LAUNCH_OR_SHOW" "$2" "$DISCORD" ;; + email ) "$LAUNCH_OR_SHOW" "$2" "$EMAIL" ;; + media ) "$LAUNCH_OR_SHOW" "$2" "$MEDIA" ;; + message ) "$LAUNCH_OR_SHOW" "$2" "$MESSAGES";; + slack ) "$LAUNCH_OR_SHOW" "$2" "$SLACK" ;; esac