Skip to content

Instantly share code, notes, and snippets.

@Floppy
Last active June 14, 2021 20:33
Show Gist options
  • Select an option

  • Save Floppy/f2d9a020df2341d974ac44024e20c7bf to your computer and use it in GitHub Desktop.

Select an option

Save Floppy/f2d9a020df2341d974ac44024e20c7bf to your computer and use it in GitHub Desktop.

Revisions

  1. Floppy revised this gist Jun 14, 2021. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions homeassistant_configuration..yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    homeassistant:
    customize: !include customize.yaml
    auth_providers:
    # Don't require login on local network
    - type: trusted_networks
    trusted_networks:
    - 192.168.1.0/24
    - 2001:xxxx:xxxx::/64
    - fe80::/10
    allow_bypass_login: true
    - type: homeassistant
  2. Floppy created this gist Jun 14, 2021.
    4 changes: 4 additions & 0 deletions snooze.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    #!/bin/bash
    sh -c "echo 0 > /sys/class/rtc/rtc0/wakealarm"
    sh -c "echo `date '+%s' -d '+ 450 minutes'` > /sys/class/rtc/rtc0/wakealarm"
    /sbin/shutdown -h now
    75 changes: 75 additions & 0 deletions tasks.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,75 @@
    ---
    - name: Install X etc
    apt:
    name:
    - xserver-xorg
    - xserver-xorg-legacy
    - x11-utils
    - xinit
    - accountsservice
    - lightdm
    - chromium-browser
    - unclutter
    state: present
    install_recommends: no

    - name: Enable auto-login to x for user
    copy:
    content: |
    [Seat:*]
    autologin-user={{ dashboard.user }}
    autologin-user-timeout=0
    user-session=xsession
    dest: /etc/lightdm/lightdm.conf.d/autologin.conf
    mode: '0644'
    notify: restart lightdm

    - name: Create Xsession directory
    file:
    path: /usr/share/xsessions
    state: directory
    mode: '0755'

    - name: Set up default Xsession
    copy:
    content: |
    [Desktop Entry]
    Name=Xsession
    Comment=Default Xsession
    Exec=/etc/X11/Xsession
    Icon=
    dest: /usr/share/xsessions/xsession.desktop
    mode: '0644'
    notify: restart lightdm

    - name: Set up xsession for user
    template:
    src: xsession.j2
    dest: "/home/{{ dashboard.user }}/.xsession"
    mode: '0644'
    notify: restart lightdm

    - name: Make sure user has passwordless sudo for running fbset command
    copy:
    content: "{{ dashboard.user }} ALL=(ALL:ALL) NOPASSWD: /bin/fbset\n"
    dest: "/etc/sudoers.d/dashboard-user"
    owner: root
    group: root
    mode: 0444
    notify: restart lightdm

    - name: Time sleep and wake
    copy:
    src: snooze.sh
    dest: "/usr/local/bin/snooze.sh"
    owner: root
    group: root
    mode: 0755

    - name: Sleep at midnight
    cron:
    name: snooze
    user: root
    hour: "0"
    minute: "0"
    job: "/usr/local/bin/snooze.sh"
    17 changes: 17 additions & 0 deletions xsession.j2
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # Set this to your URL - it must return a 200 OK when called, not a redirect.
    export URL={{dashboard.url}}

    # Dont want screensavers or screen blanking
    xset s off &
    xset -dpms &
    xset s noblank &

    # Hide the mouse cursor
    unclutter -idle 10 -noevents &

    # get screen resolution
    WIDTH=`sudo fbset -s | grep "geometry" | cut -d " " -f6`
    HEIGHT=`sudo fbset -s | grep "geometry" | cut -d " " -f7`

    # Open chrome in incognito mode + kiosk mode
    /usr/bin/chromium-browser --window-size=${WIDTH},${HEIGHT} --window-position=0,0 --hide-scrollbars --incognito --kiosk ${URL}