summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5e144552b8bef700e5bfd81f52c36b9c132c93dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Maintainer: Alex S. shantanna_at_hotmail_dot_com>

pkgname=display-mode-switcher
_pkgname=dispswitch
pkgver=0.1
pkgrel=1
pkgdesc="The simple application to switch the display with one click between single and dual mode"
arch=('any')
url="http://aur.archlinux.org/packages/display-mode-switcher/"
license=('BSD')
depends=('gnome-shell')

package() {
  msg2 "Creating launcher..."
  cd "${srcdir}" || exit
  cat > "${srcdir}/Display mode switcher.desktop" << EOF
#!/usr/bin/env xdg-open
[Desktop Entry]
Type=Application
Name=Display mode switcher
Comment=The simple program to switch the display with one klick betwin single and dual mode
Exec=/usr/bin/${_pkgname}
Icon=preferences-desktop-display
Terminal=false
Categories=GNOME;GTK;Settings;HardwareSettings;
EOF
  install -Dm644 Display\ mode\ switcher.desktop "${pkgdir}/usr/share/applications/Display mode switcher.desktop"

  msg2 "Creating application..."
  cat > "${srcdir}/${_pkgname}" << 'EOF'
#!/bin/sh

prim_disp=$(xrandr | grep '\<connected primary\>' | awk 'NR==1 { print $1 }')
sec_disp=$(xrandr | grep '\<connected\>' | sed '/primary/d' | awk 'NR==1 { print $1 }')

if [ ! "$sec_disp" ]; then
  notify-send "No additional display(s) connected"
else
  case $@ in
  -on|-ON)
    xrandr --output $sec_disp --right-of $prim_disp --auto
    notify-send "Multi-display mode is ON"
    ;;
  -off|-OFF)
    xrandr --output $sec_disp --off
    notify-send "Multi-display mode is OFF"
    ;;
  *)
    if [ "$#" -eq "0" ] && [ ! "`xrandr | grep -E "$sec_disp connected [[:digit:]]"`" ]; then
      xrandr --output $sec_disp --right-of $prim_disp --auto
      notify-send "Multi-display mode is ON"
    elif [ "$#" -eq "0" ] && [ "`xrandr | grep -E "$sec_disp connected [[:digit:]]"`" ]; then
      xrandr --output $sec_disp --off
      notify-send "Multi-display mode is OFF"
    fi
    ;;
  esac
fi
exit 0
EOF
  install -Dm755 ${_pkgname} "${pkgdir}/usr/bin/${_pkgname}"
  chmod +x "${pkgdir}/usr/bin/${_pkgname}"
}