summaryrefslogtreecommitdiff
path: root/ar/.local/bin/yt-music
blob: 795403f336ac13c9ad5f25b9a2881e61bb74793e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"

if [ -f "$XDG_CONFIG_HOME/youtube-music-flags.conf" ]; then
  YOUTUBE_MUSIC_USER_FLAGS="$(grep -v '^#' "$XDG_CONFIG_HOME/youtube-music-flags.conf")"
fi

export ELECTRON_IS_DEV=0
"/opt/YouTube Music/youtube-music" $YOUTUBE_MUSIC_USER_FLAGS "$@" &
APP_PID=$!

# Wait for the main window, then override WM_CLASS set by Electron
i=0
while [ "$i" -lt 50 ]; do
  WID=$(xdotool search --classname "com.github.th_ch.youtube_music" 2>/dev/null | tail -1)
  if [ -n "$WID" ]; then
    xdotool set_window --classname "yt-music" --class "yt-music" "$WID"
    break
  fi
  sleep 0.2
  i=$((i + 1))
done