Skip to content

Commit

Permalink
Merge pull request #63 from samueldr-wip/feature/better-demo
Browse files Browse the repository at this point in the history
Make the demo more useful on a touch device
  • Loading branch information
samueldr committed Dec 6, 2019
2 parents 2edfa09 + b228b71 commit c390bbe
Show file tree
Hide file tree
Showing 10 changed files with 1,065 additions and 17 deletions.
Binary file added artwork/wallpapers/mobile-nixos-19.09.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
604 changes: 604 additions & 0 deletions artwork/wallpapers/mobile-nixos-19.09.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
164 changes: 148 additions & 16 deletions examples/demo/configuration.nix
Expand Up @@ -2,28 +2,41 @@

let
inherit (lib) mkForce;
system_type = config.mobile.system.type;

# Why copy them all?
# Because otherwise the wallpaper picker will default to /nix/store as a path
# and this could get messy with the amazing amount of files there are in there.
# Why copy only pngs?
# Rendering of `svg` is hard! Not that it's costly in cpu time, but that the
# rendering might not be as expected depending on what renders it.
# The SVGs in that directory are used as an authoring format files, not files
# to be used as they are. They need to be pre-rendered.
wallpapers = pkgs.runCommandNoCC "wallpapers" {} ''
mkdir -p $out/
cp ${../../artwork/wallpapers}/*.png $out/
'';
in
{
imports = [
../../profiles/installer.nix
];
disabledModules = [
<nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix>
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-base.nix>
];
{
imports = [
../../profiles/installer.nix
];

disabledModules = [
<nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix>
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-base.nix>
];

config = lib.mkMerge [
{

boot.growPartition = lib.mkDefault true;

services.xserver = {
enable = true;

libinput.enable = true;
videoDrivers = [ "fbdev" ];

# xfce has been chosen mainly because it is light, and quick to start.
# FIXME: Find a better demo environment.
desktopManager.xfce.enable = true;
videoDrivers = lib.mkDefault [ "fbdev" ];

# Automatically login as nixos.
displayManager.lightdm = {
Expand All @@ -35,12 +48,14 @@ in
};

};

powerManagement.enable = true;
hardware.pulseaudio.enable = true;

environment.systemPackages = with pkgs; [
firefox
(writeShellScriptBin "firefox" ''
export MOZ_USE_XINPUT2=1
exec ${pkgs.firefox}/bin/firefox "$@"
'')
sgtpuzzles
hard-reboot
hard-shutdown
Expand Down Expand Up @@ -85,8 +100,11 @@ in
networking.networkmanager.enable = true;
networking.networkmanager.unmanaged = [ "rndis0" "usb0" ];

services.blueman.enable = true;
hardware.bluetooth.enable = true;

# Setup USB gadget networking in initrd...
mobile.boot.stage-1.networking.enable = true;
mobile.boot.stage-1.networking.enable = lib.mkDefault true;
#mobile.boot.stage-1.ssh.enable = true;

# Start SSH by default...
Expand All @@ -105,5 +123,119 @@ in
# FIXME : figure out why systemd-udev-settle doesn't work.
systemd.services.systemd-udev-settle.enable = false;
}

# Customized XFCE environment
{
services.xserver = {
desktopManager.xfce.enable = true;
};

environment.systemPackages = with pkgs; [
adapta-gtk-theme
breeze-icons
];

fonts.fonts = with pkgs; [
aileron
];

environment.etc."xdg/xfce4" = {
# TODO: DPI/size settings, so that a DPI can be derived from the device info.
source = pkgs.runCommandNoCC "xfce4-defaults" {} ''
cp -r ${./xdg/xfce4} $out
wallpaper="${wallpapers}/mobile-nixos-19.09.png"
substituteInPlace $out/xfconf/xfce-perchannel-xml/xfce4-desktop.xml \
--subst-var wallpaper
'';
};
}

# Replace xfwm with awesome with a custom config.
{
services.xserver = {
desktopManager.xfce.enableXfwm = false;
desktopManager.xfce.extraSessionCommands = ''
awesome &
'';
};

environment.systemPackages = with pkgs;
let
close = writeShellScript "action-close-window" ''
awesome-client '
local awful = require("awful");
local c = awful.client.focus.filter(client.focus)
if c then
c:kill()
end
'
'';
in
[
awesome
(runCommandNoCC "awesome-actions" {} ''
mkdir -vp $out/share/applications/
(cd $out/share/applications/
cat > awesome-close.desktop <<EOF
[Desktop Entry]
Name=Close active window
Exec=${close}
Icon=process-stop
EOF
)
''/* TODO: better icon than process-stop */)
];

environment.etc."xdg/awesome" = {
source = ./xdg/awesome;
};

services.unclutter.enable = true;
}

# Onboard on-screen keyboard
{
environment.systemPackages = with pkgs; [
onboard
];
environment.etc."xdg/autostart/onboard-boottime-configuration.desktop" = {
text = let script = pkgs.writeShellScript "onboard-boottime-configuration" ''
set -u
set -e
# A bit rude, but this ensures the keyboard always starts at a quarter
# of the resolution.
# onboard will not accept -s to set size with a docked keyboard.
height=$(( $( ${pkgs.xlibs.xwininfo}/bin/xwininfo -root | grep '^\s\+Height:' | cut -d':' -f2 ) / 4 ))
${pkgs.gnome3.dconf}/bin/dconf write /org/onboard/window/landscape/dock-height "$height" || :
${pkgs.gnome3.dconf}/bin/dconf write /org/onboard/window/portrait/dock-height "$height" || :
'';
in ''
[Desktop Entry]
Name=Onboard boot time configuration
Exec=${script}
X-XFCE-Autostart-Override=true
'';
};
environment.etc."xdg/autostart/onboard-autostart.desktop" = {
source = pkgs.runCommandNoCC "onboard-autostart.desktop" {} ''
cat "${pkgs.onboard}/etc/xdg/autostart/onboard-autostart.desktop" > $out
echo "X-XFCE-Autostart-Override=true" >> $out
substituteInPlace $out \
--replace "Icon=onboard" "Icon=input-keyboard"
'';
};
}

# FIXME : depthcharge is the wrong assumption.
# A better abstraction over the X11 stack is required within mobile-nixos.
# The qemu VM requires the fbdev one to work as expcted.
# The android devices may have hwcomposer stuff coming.
(lib.mkIf (system_type == "depthcharge") {
services.xserver = {
videoDrivers = [ "modesetting" ];
};
})
];
}
9 changes: 8 additions & 1 deletion examples/demo/default.nix
Expand Up @@ -10,6 +10,13 @@ let
};
in
{
inherit (system-build.build) android-bootimg android-device;
inherit (system-build.build)
# Android devices
android-bootimg android-device
# QEMU VM
vm
# Depthcharge
disk-image
;
android-burn-tool = burn-tool-build.build.android-bootimg;
}
114 changes: 114 additions & 0 deletions examples/demo/xdg/awesome/rc.lua
@@ -0,0 +1,114 @@
--
-- Minimal "one window at a time" configuration.
--
-- There are no features. No keyboard control.
--

local awful = require("awful")
awful.rules = require("awful.rules")
require("awful.autofocus")

-- {{{ Layout

-- Table of layouts to cover with awful.layout.inc, order matters.
local layouts = {
-- awful.layout.suit.tile,
-- awful.layout.suit.tile.left,
-- awful.layout.suit.tile.bottom,
-- awful.layout.suit.tile.top,
-- awful.layout.suit.fair,
-- awful.layout.suit.fair.horizontal,
-- awful.layout.suit.spiral,
-- awful.layout.suit.spiral.dwindle,
awful.layout.suit.max,
-- awful.layout.suit.max.fullscreen,
-- awful.layout.suit.magnifier,
-- awful.layout.suit.floating,
}

-- }}}

-- {{{ Tags
local tags = {}
awful.screen.connect_for_each_screen(function(s)
tags[s] = awful.tag({"1"}, s, layouts[1])
end)
-- }}}

-- {{{ Wibox
local mywibox = {}
awful.screen.connect_for_each_screen(function(s)
-- Hmmm, this is weird, but I *have* to add a wibar.
-- Otherwise awesome will not resize windows when onboard resizes...
-- Weird, eh?
mywibox[s] = awful.wibar({ position = "top", screen = s, visible = false })
end)
-- }}}

-- {{{ Rules
awful.rules.rules = {
-- All clients will match this rule.
{ rule = { },
properties = {
border_width = 0,
focus = awful.client.focus.filter,
raise = true,
placement = awful.placement.no_overlap+awful.placement.no_offscreen,
}
},

-- XFCE notification
-- Otherwise all notifications will interrupt input with a HW (bluetooth) keyboard
{ rule = { instance = "xfce4-notifyd", class = "Xfce4-notifyd" },
properties = {
border_width = 0,
sticky = true,
focusable = false,
nofocus = true,
ontop = true;
}
},

-- Onboard on-screen keyboard
{ rule = { instance = "onboard", class = "Onboard" },
properties = {
border_width = 0,
sticky = true,
focusable = false,
nofocus = true,
ontop = true;
}
},

-- Xfce desktop
-- Allows its use in all tags.
{ rule = { instance = "xfdesktop", class = "Xfdesktop" },
properties = {
border_width = 0,
sticky = true,
focusable = false,
nofocus = true,
}
},

}
-- }}}

-- {{{ Signals

-- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c, startup)
if not startup then
-- Set the windows at the slave,
-- i.e. put it at the end of others instead of setting it master.
-- awful.client.setslave(c)

-- Put windows in a smart way, only if they does not set an initial position.
if not c.size_hints.user_position and not c.size_hints.program_position then
awful.placement.no_overlap(c)
awful.placement.no_offscreen(c)
end
end
end)

-- }}}
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>

<channel name="xfce4-desktop" version="1.0">
<property name="backdrop" type="empty">
<property name="screen0" type="empty">
<property name="monitor0" type="empty">
<property name="workspace0" type="empty">
<property name="color-style" type="int" value="0"/>
<property name="image-style" type="int" value="5"/>
<property name="last-image" type="string" value="@wallpaper@"/>
</property>
</property>
</property>
</property>
<property name="desktop-menu" type="empty">
<property name="show" type="bool" value="false"/>
</property>
<property name="windowlist-menu" type="empty">
<property name="show" type="bool" value="false"/>
</property>
<property name="desktop-icons" type="empty">
<property name="file-icons" type="empty">
<property name="show-filesystem" type="bool" value="false"/>
<property name="show-removable" type="bool" value="false"/>
</property>
<property name="single-click" type="bool" value="true"/>
<property name="show-tooltips" type="bool" value="false"/>
<property name="use-custom-font-size" type="bool" value="true"/>
<property name="font-size" type="double" value="10.000000"/>
<property name="icon-size" type="uint" value="96"/>
</property>
</channel>

0 comments on commit c390bbe

Please sign in to comment.