Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
675 changes: 675 additions & 0 deletions screen-recorder@kprakesh/LICENSE

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions screen-recorder@kprakesh/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Screen Recorder Applet for Linux Mint Cinnamon

A lightweight, easy-to-use Cinnamon desktop applet that lets you record your screen and system audio directly from the panel. Built using standard Cinnamon JavaScript (CJS) and powered by `ffmpeg`.

## Features
* **Quick Access:** Start and stop screen recordings from a simple panel popup menu.
* **Visual Status:** The panel icon turns red and displays a "REC" label while a recording is actively in progress.
* **Smart Capture:** Automatically detects and adapts to your primary monitor's exact screen resolution, preventing out-of-bounds errors.
* **Customizable Settings:** * Toggle system audio recording on or off.
* Choose your preferred video output format (MP4, WebM, or MKV).
* Select a custom destination folder for your saved recordings.
* **Auto-saving:** Recordings are automatically finalized and saved to your chosen directory (defaults to `~/Videos`) with a precise timestamp.

## Prerequisites
This applet relies on `ffmpeg` as the backend recording engine. It is natively available on Linux Mint.

Before installing, you can easily check if you already have it on your system by opening your terminal and running `ffmpeg -version`. If it is not installed or recognized, you can add it by running:

```bash
sudo apt update
sudo apt install ffmpeg
```
147 changes: 147 additions & 0 deletions screen-recorder@kprakesh/files/screen-recorder@kprakesh/applet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@

/**
* Screen Recorder
* Copyright (C) 2026 kprakesh
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/



const Applet = imports.ui.applet;
const Util = imports.misc.util;
const GLib = imports.gi.GLib;
const PopupMenu = imports.ui.popupMenu;
const St = imports.gi.St;
const Settings = imports.ui.settings;
const Main = imports.ui.main;

class ScreenRecorderApplet extends Applet.TextIconApplet {
constructor(metadata, orientation, panel_height, instance_id) {
super(orientation, panel_height, instance_id);

this.metadata = metadata;

this.settings = new Settings.AppletSettings(this, metadata.uuid, instance_id);
this.settings.bind("record-audio", "recordAudio");
this.settings.bind("output-format", "outputFormat");
//this.settings.bind("video-resolution", "videoResolution");
this.settings.bind("save-directory", "saveDirectory");

this.isRecording = false;

this.set_applet_icon_symbolic_name("camera-video-symbolic");
this.set_applet_label("");
this.set_applet_tooltip("Screen Recorder");

this.menuManager = new PopupMenu.PopupMenuManager(this);
this.menu = new Applet.AppletPopupMenu(this, orientation);
this.menuManager.addMenu(this.menu);

// Create the Start/Stop Toggle Menu Item
this.recordMenuItem = new PopupMenu.PopupIconMenuItem(
"Start Recording",
"media-record",
St.IconType.SYMBOLIC
);

this.recordMenuItem.connect('activate', () => this.toggleRecording());

this.menu.addMenuItem(this.recordMenuItem);
}

on_applet_clicked() {
this.menu.toggle();
}

toggleRecording() {
if (!this.isRecording) {
this.startRecording();
} else {
this.stopRecording();
}
}

// Ensure ffmpeg is installed before attempting to record; notify user if missing
checkDependencies() {
if (!GLib.find_program_in_path("ffmpeg")) {
let title = "Screen Recorder: Dependency Missing";
let msg = "Please open your terminal and run:\n\nsudo apt install ffmpeg";

Main.notify(title, msg);

return false;
}
return true;
}

startRecording() {

if (!this.checkDependencies()) return;

let monitor = Main.layoutManager.primaryMonitor;
let screen_resolution = `${monitor.width}x${monitor.height}`;
let now = GLib.DateTime.new_now_local();
let timestamp = now.format("%Y-%m-%d_%H-%M-%S");

let save_dir = this.saveDirectory.replace("~", GLib.get_home_dir());
let output_file = `${save_dir}/ScreenRecord_${timestamp}.${this.outputFormat}`;

// Properly escape the path for the shell
let escaped_output = GLib.shell_quote(output_file);

let audio_flag = this.recordAudio ? "-f pulse -i $(pactl get-default-sink).monitor" : "";
let codec_flags = (this.outputFormat === "webm")
? "-c:v libvpx -crf 10 -b:v 1M -c:a libvorbis"
: "-c:v libx264 -preset ultrafast -c:a aac";

let ffmpeg_cmd = `ffmpeg -video_size ${screen_resolution} -framerate 30 -f x11grab -i :0.0 ${audio_flag} ${codec_flags} ${escaped_output}`;

// Use GLib to spawn so we can track the PID
let [success, argv] = GLib.shell_parse_argv(`bash -c '${ffmpeg_cmd}'`);
if (success) {
let [result, pid] = GLib.spawn_async(null, argv, null, GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD, null);
this.current_pid = pid;

GLib.child_watch_add(GLib.PRIORITY_DEFAULT, this.current_pid, (pid, status) => {
if (this.isRecording) this.stopRecording(true); // Reset UI if ffmpeg dies
GLib.spawn_close_pid(pid);
});
}

this.set_applet_icon_symbolic_name("media-playback-stop");
this.set_applet_label("REC");
this._applet_icon.style = "color: #ff4444;";
this.recordMenuItem.label.set_text("Stop Recording");
this.isRecording = true;
}

stopRecording(was_crash = false) {
if (this.current_pid && !was_crash) {
Util.spawn(["kill", "-SIGINT", this.current_pid.toString()]);
}
this.current_pid = null;

this.set_applet_icon_symbolic_name("camera-video-symbolic");
this.set_applet_label("");
this._applet_icon.style = "";
this.recordMenuItem.label.set_text("Start Recording");
this.set_applet_tooltip("Screen Recorder");
this.isRecording = false;
}
}

function main(metadata, orientation, panel_height, instance_id) {
return new ScreenRecorderApplet(metadata, orientation, panel_height, instance_id);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"uuid": "screen-recorder@kprakesh",
"name": "Screen Recorder",
"description": "Click to record screen and audio",
"icon": "icon.svg",
"max-instances": 1,
"version": "1.0",
"multiversion": true,
"cinnamon-version": [
"5.0",
"5.2",
"5.4",
"5.6",
"5.8",
"6.0",
"6.2",
"6.4"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"layout": {
"type": "header",
"description": "Recording Settings"
},
"record-audio": {
"type": "checkbox",
"default": true,
"description": "Record system audio"
},
"output-format": {
"type": "combobox",
"default": "mp4",
"description": "Video output format",
"options": {
"MP4 (Standard)": "mp4",
"WebM (Free/Open)": "webm",
"MKV (Matroska)": "mkv"
}
},
"save-directory": {
"type": "filechooser",
"select-dir": true,
"default": "~/Videos",
"description": "Save recordings to folder"
}
}
8 changes: 8 additions & 0 deletions screen-recorder@kprakesh/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"uuid": "screen-recorder@kprakesh",
"name": "Screen Recorder",
"description": "Click to record screen and audio",
"author": "kprakesh",
"icon": "icon.svg",
"license": "GPL-3.0"
}
Binary file added screen-recorder@kprakesh/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading