Coder Social home page Coder Social logo

xiaoshzx / display-utility Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kousiksatish/display-utility

0.0 1.0 0.0 3.92 MB

Utility to retrieve the information about the desktop display like number of outputs, output names, current resolution and list of resolutions using xrandr.

License: MIT License

Python 1.26% C++ 50.43% TypeScript 6.18% C 42.12%

display-utility's Introduction

Display Utility

Linux utility to

  1. Display information about the X11 desktop display like number of outputs, output names, current resolution and list of possible resolutions for all outputs using X11 and xrandr C libraries.
  2. Capture screen as a RGB bitmap, encode using x264 and output continuous video frames.
  3. Lock screen of any linux desktop using lock-system package.

Usage

Install from NPM to your dependencies

npm install @idrive-remotepc/display-utility

Import the various utilities as required from the package

Typescipt

import { displayUtility, lockUtility, screenCaptureUtility } from '@idrive-remotepc/display-utility';

Javascript

const { displayUtility, lockUtility, screenCaptureUtility } = require('@idrive-remotepc/display-utility');

Functions exposed

displayUtility.getConnectedOutputs(): number[] | undefined

Returns list of numbers which represents the RROutput corresponding to all the outputs.

displayUtility.getOutputName(rROutput: number): string

Returns the name of the output (monitor) given the RROutput number for that output

displayUtility.getCurrentResolution(rROutput: number): IResolution | undefined

Returns the current resolution of the output (monitor) given the RROutput number for that output

displayUtility.getResolutions(rROutput: number): IResolution[] | undefined

Returns the list of possible resolutions for an output (montior) given the RROutput number for that output

displayUtility.setResolution(rROutput: number, resolution: IResolution): void

Sets a particular resolution for an output (monitor) given the RROutput number for that output and the new resolution to be set.

displayUtility.makeScreenBlank(): void

Reduces the brightness of all connected outputs to 0 and makes the screen blank.

displayUtility.reverseBlankScreen(): void

Reverses the operation performed by makeScreenBlank()

displayUtility.getPrimaryRROutput(): number

Get the RROutput number corresponding to the primary monitor

Note: When no monitor is marked as primary, one of the connected monitor's RROutput number is returned

displayUtility.getExtendedMonitorResolution: IResolution | undefined

Get the complete resolution of the display when multiple monitors are connected.

Note: Returns same value as getCurrentResolution(), when single monitor is connected

displayUtility.getAllCurrentResolutionsWithOffset(): IResolutionWithOffset[] | undefined

Get the position (x-offset and y-offset), height and width of connected monitors

screenCaptureUtility.init(singleMonitorCapture: boolean, rROutput?: number): void

Initialises the screen capturer and x264 encoder for capturing screen.

To capture a single output (monitor) with RROutput number 65 (example):

screenCaptureUtility.init(true, 65);

To capture the complete display including all connected outputs (monitors):

screenCaptureUtility.init();

screenCaptureUtility.getNextFrame(callback: (nextFrame: ArrayBuffer) => void): void

Returns the captured and encoded frame buffer as a callback.

screenCaptureUtility.getNextFrame((frame: ArrayBuffer) => {
    // perform operation with frame
});

lockUtility.lockScreen(): void

Locks the computer when executed

Issues

Please feel free to raise issues on this repository, be it bugs or feature requests. We would be happy to address them.

Debugging

Debugging the native node modules is possible using lldb extension in Visual Studio Code. Following are the steps:

  1. Install recommended vscode extension vadimcn.vscode-lldb.

  2. Install lldb in your system if it is not already installed.

    # For debian
    apt install lldb
    
    # For RPM
    yum install lldb
  3. Write required functions to debug in test.ts and start debugging using F5.

display-utility's People

Contributors

kousiksatish avatar bavulapati avatar bhagyashreesoni avatar rpclinux avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.