Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Created September 19, 2020 12:13
Show Gist options
  • Save cleverca22/2f694e612f39e29bb75ac0bfd82141b0 to your computer and use it in GitHub Desktop.
Save cleverca22/2f694e612f39e29bb75ac0bfd82141b0 to your computer and use it in GitHub Desktop.
{ pkgs, ... }:
let
kioskUsername = "kiosk";
browser = pkgs.firefox;
rcfile = ''
<?xml version="1.0" encoding="UTF-8"?>
<openbox_config xmlns="http://openbox.org/3.4/rc">
<applications>
<application class="*">
<decor>no</decor>
</application>
</applications>
</openbox_config>
'';
autostart = ''
#!${pkgs.bash}/bin/bash
# End all lines with '&' to not halt startup script execution
# https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options
echo "this will be a great presentation" > pre.txt
sent pre.txt &
# firefox --kiosk https://impress.js.org/#/bored &
'';
inherit (pkgs) writeScript;
in {
# Set up kiosk user
users.users = {
"${kioskUsername}" = {
group = kioskUsername;
isNormalUser = true;
packages = [ browser ];
initialPassword = "test";
extraGroups = [ "video" ];
};
};
users.groups."${kioskUsername}" = { };
# Configure X11
services.xserver = {
enable = true;
layout = "us"; # keyboard layout
libinput.enable = true;
# Let lightdm handle autologin
displayManager.lightdm = {
enable = true;
autoLogin = {
enable = true;
timeout = 0;
user = kioskUsername;
};
};
# Start openbox after autologin
windowManager.openbox.enable = true;
displayManager.defaultSession = "none+openbox";
};
# Overlay to set custom autostart script for openbox
nixpkgs.overlays = with pkgs; [
(self: super: {
openbox = super.openbox.overrideAttrs (oldAttrs: rec {
postFixup = ''
ln -sf /etc/openbox/autostart $out/etc/xdg/openbox/autostart
'';
});
})
];
# By defining the script source outside of the overlay, we don't have to
# rebuild the package every time we change the startup script.
# pdfpc pympress jfbpdf xpdf
environment.etc."openbox/autostart".source = writeScript "autostart" autostart;
environment.etc."openbox/rc.xml".text = ${rcfile}
environment.systemPackages = with pkgs; [ sent plymouth pdfpc ];
boot.plymouth.enable = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment