Skip to content

Commit

Permalink
FMO-55: Add screen recording executor on top panel
Browse files Browse the repository at this point in the history
- Create screen recording script
- Add screen recording script as an executor in nwg-panel and place on top right module

Signed-off-by: Anh Huy Bui <[email protected]>
  • Loading branch information
buianhhuy96 committed Oct 26, 2024
1 parent 6acc20a commit 5143abe
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 3 deletions.
Binary file added modules/desktop/graphics/assets/record.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/desktop/graphics/assets/stop-record.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 22 additions & 1 deletion modules/desktop/graphics/sway/nwg-panel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,29 @@
};
};

Executors = {
executor-recording = {
script = "${pkgs.screenRecord}/bin/screenRecord";
tooltip-text = "";
on-left-click = "${pkgs.screenRecord}/bin/screenRecord s";
on-middle-click = "";
on-right-click = "";
on-scroll-up = "";
on-scroll-down = "";
root-css-name = "";
css-name = "";
icon-placement = "left";
icon-size = 25;
interval = 1;
angle = 0.0;
sigrt = 34;
use-sigrt = false;
};
};

panel-top-modules = {
modules-left = (mkLauncherModules config.ghaf.graphics.app-launchers.launchers);
modules-right = [ "tray" "executor-cpu" "executor-memory" "keyboard-layout" "executor-recording" ];
};

panel-bottom-modules = {
Expand All @@ -101,7 +122,7 @@
};

panelConfig = builtins.toJSON [
(panelTopConfig // launcherIcons
(panelTopConfig // launcherIcons // Executors
// panel-top-modules)

(panelBottomConfig // powerIcons // keyboardIcons // wsSwitchIcons
Expand Down
7 changes: 5 additions & 2 deletions modules/desktop/graphics/sway/sway.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ in

# Refer in https://nixos.wiki/wiki/Sway
#TODO: remove some unused apps
environment.systemPackages = with pkgs; [
alacritty # gpu accelerated terminal
environment.systemPackages = with pkgs; [
jq
screenRecord
wf-recorder
killall
dbus-sway-environment
configure-gtk
wayland
Expand Down
1 change: 1 addition & 0 deletions modules/packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ _: {
(import ./nmLauncher)
(import ./nwg-panel)
(import ./registration-agent)
(import ./screen-recorder)
(import ./squeekboard)
(import ./sway-scripts)
(import ./terminator)
Expand Down
30 changes: 30 additions & 0 deletions modules/packages/screen-recorder/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
(final: _prev: {
screenRecord = final.writeShellScriptBin "screenRecord" ''
RECORDING_STATE=$(${final.ps}/bin/ps cax -o stat,comm | grep '^S.*wf-recorder')
FILE_NAME="/home/ghaf/recordings/$(date '+%Y-%m-%d_%H:%M:%S').mp4"
CURRENT_DISPLAY=$(${final.sway}/bin/swaymsg -t get_outputs --raw | ${final.jq}/bin/jq '. | map(select(.focused == true)) | .[0].name' -r)
if [ $# == 0 ]; then
if [[ -z $RECORDING_STATE ]]; then
echo ${../../desktop/graphics/assets/record.png}
echo "$CURRENT_DISPLAY"
else
echo ${../../desktop/graphics/assets/stop-record.png}
echo Recording
fi
exit
fi
if [[ "$1" != "s" ]] then
exit
fi
if [[ -z $RECORDING_STATE ]]; then
mkdir -p /home/ghaf/recordings
${final.coreutils-full}/bin/nohup ${final.wf-recorder}/bin/wf-recorder -a -f $FILE_NAME -o $CURRENT_DISPLAY </dev/null &>/dev/null &
echo Started
else
${final.killall}/bin/killall -s SIGINT wf-recorder
echo Stopped
fi
'';
})

0 comments on commit 5143abe

Please sign in to comment.