Skip to content

ardijanr/screen-modes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Screen Mode Selector

Easy toggle between modes for two monitors.

Makes changing monitor layout simpler and faster.

Comes in handy when you have to present something or just want to enable your display.

Bind it to a key for optimal handyness.

Standalone application

Source code depends on:

Requires xrandr.

Opens a floating window that lets you click on what screen you want active and immediately closes after click/enter, built entierly in rust, using the iced GUI library.

Keybindings

  • Key( 1 ) -- Primary Screen Only (eDP)
  • Key( 2 ) -- First Secondary screen only
  • Key( 3 ) -- Duplicate
  • Key( 4 ) -- Extend using --auto command
  • Key( Q ) -- Exit
  • Key( Esc ) -- Exit

Features:

  • Display only on Primary monitor
  • Display only on Secondary monitor
  • Duplicate screens, (actual duplicate, highest common resolution)
  • Extend (highest available on both monitors)

Future Features:

  • Screen position left or right (defaults to left right now) For now either change the source code argument where it says "--left-off" to "--right-of" in the main.rs file and recompile. or complain about it and it might happen sooner...

Installation/How to use

Compile or download binary and place it in for example ~/.local/bin (create if necessary)

Example for keyboard shortcut binding in i3:

bindsym --release $mod+F2 exec --no-startup-id ~/.bin/screen_toggle

Example nixos install:


{ config, lib, pkgs, ... }:

let
  url = "https://github.com/ardijanr/screen-modes/releases/download/latest/screen_mode";
  sha256 = "1wcngmhif8csv6iv9wh2w3gkrgh4f0gb0vkmkgxhfp89kdhb4jx1";

  runtimeDeps = with pkgs; [
    xorg.libX11
    xorg.libXcursor
    xorg.libXi
    xorg.libXrandr
  ];

  screenMode = pkgs.stdenv.mkDerivation {
    pname = "screen_mode";
    version = "0.1.0";
    src = pkgs.fetchurl {
      url = url;
      sha256 = sha256;
    };

    buildInputs = runtimeDeps;

    dontUnpack = true;

    installPhase = ''
      mkdir -p $out/bin
      cp $src $out/bin/screen_mode
      chmod +x $out/bin/screen_mode
    '';

    makeWrapperArgs = [
      "--set" "LD_LIBRARY_PATH" "${lib.makeLibraryPath runtimeDeps}"
    ];

    nativeBuildInputs = [ pkgs.makeWrapper ];

    postFixup = ''
      wrapProgram $out/bin/screen_mode ''${makeWrapperArgs[@]}
    '';

    meta = with lib; {
      description = "Select how external monitors should behave";
      homepage = "https://github.com/ardijanr/screen-modes";
      license = licenses.mit;
      maintainers = with maintainers; [ "ardijanr" ];
    };
  };
in
{
  home.packages = [
    screenMode
  ];
}