diff --git a/README.md b/README.md index 2f66de8..5c8a708 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ Simple application VM's based on Nix package manager. Designed primarily for full screen usage without guest additions. -By default uses 3840x2160, so you need to change `appvm/nix/base.nix` monitorSection. Autodetection based on host resolution will be done after. - It's a proof-of-concept, but you can still use it. Also there is a lot of strange things inside, don't afraid of :) ## Install Nix package manager @@ -23,9 +21,17 @@ It's a proof-of-concept, but you can still use it. Also there is a lot of strang (if you clone appvm to home directory) +## Generate resolution + +By default uses 3840x2160. If you need to regenerate `appvm/nix/monitor.nix`: + + $ appvm/appvm.sh generate-resolution 1920 1080 > appvm/nix/monitor.nix + +Autodetection is a bash-spaghetti, so you need to check results. BTW it's just a X.org monitor section. + ## Create VM - $ $HOME/appvm/appvm.sh chromium + $ $HOME/appvm/appvm.sh build chromium ## Run application diff --git a/appvm.sh b/appvm.sh index 3044544..e266e13 100755 --- a/appvm.sh +++ b/appvm.sh @@ -19,6 +19,17 @@ if [[ "$1" == "build" && "$2" != "" ]]; then chmod +x ${VM_BIN_PATH} chmod +x bin/appvm.${2} unlink result +elif [[ "$1" == "generate-resolution" && "$2" != "" && "$3" != "" ]]; then + MONITOR_SIZE="$(xrandr | grep mm | head -n 1 | awk '{ print $(NF-2) " " $(NF) }' | sed 's/mm//g')" + CVT="$(cvt ${2} ${3} | grep Modeline)" + echo "{" + echo " services.xserver.monitorSection = ''" + echo " " ${CVT} + echo " " Option '"PreferredMode"' $(echo ${CVT} | awk '{ print $2 }') + echo " " DisplaySize ${MONITOR_SIZE} # In millimeters + echo " '';" + echo "}" else - echo "Usage: $0 build APPLICATION" + echo -e "Usage:\t$0 build APPLICATION" + echo -e "or:\t$0 generate-resolution X Y" fi diff --git a/nix/base.nix b/nix/base.nix index 57159ff..0416d4d 100644 --- a/nix/base.nix +++ b/nix/base.nix @@ -1,4 +1,8 @@ { + imports = [ + + ]; + system.nixos.stateVersion = "18.03"; services.xserver = { diff --git a/nix/monitor.nix b/nix/monitor.nix new file mode 100644 index 0000000..8caebd1 --- /dev/null +++ b/nix/monitor.nix @@ -0,0 +1,7 @@ +{ + services.xserver.monitorSection = '' + Modeline "3840x2160_60.00" 712.75 3840 4160 4576 5312 2160 2163 2168 2237 -hsync +vsync + Option "PreferredMode" "3840x2160_60.00" + DisplaySize 610 350 + ''; +}