Implemented screen recording functionality for record button in dashboard.
This commit is contained in:
@@ -9,7 +9,6 @@ import { Bluetooth } from "./bluetooth/index.js";
|
|||||||
import { BatteryLabel } from "./battery/index.js";
|
import { BatteryLabel } from "./battery/index.js";
|
||||||
import { Clock } from "./clock/index.js";
|
import { Clock } from "./clock/index.js";
|
||||||
import { SysTray } from "./systray/index.js";
|
import { SysTray } from "./systray/index.js";
|
||||||
import { Power } from "./power/index.js";
|
|
||||||
|
|
||||||
import { BarItemBox } from "../shared/barItemBox.js";
|
import { BarItemBox } from "../shared/barItemBox.js";
|
||||||
|
|
||||||
@@ -52,9 +51,8 @@ const Right = () => {
|
|||||||
BarItemBox(Bluetooth()),
|
BarItemBox(Bluetooth()),
|
||||||
BarItemBox(BatteryLabel()),
|
BarItemBox(BatteryLabel()),
|
||||||
BarItemBox(SysTray()),
|
BarItemBox(SysTray()),
|
||||||
BarItemBox(Notifications()),
|
|
||||||
BarItemBox(Clock()),
|
BarItemBox(Clock()),
|
||||||
BarItemBox(Power()),
|
BarItemBox(Notifications()),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -86,7 +84,6 @@ const RightAlt = () => {
|
|||||||
children: [
|
children: [
|
||||||
BarItemBox(Volume()),
|
BarItemBox(Volume()),
|
||||||
BarItemBox(Clock()),
|
BarItemBox(Clock()),
|
||||||
BarItemBox(Power()),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,10 +1,30 @@
|
|||||||
|
const hyprland = await Service.import("hyprland");
|
||||||
|
|
||||||
const Shortcuts = () => {
|
const Shortcuts = () => {
|
||||||
const handleClick = (action) => {
|
const isRecording = Variable(false, {
|
||||||
|
poll: [
|
||||||
|
1000,
|
||||||
|
`${App.configDir}/services/screen_record.sh status`,
|
||||||
|
(out) => {
|
||||||
|
if (out === "recording") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
const handleClick = (action, resolver) => {
|
||||||
App.closeWindow("dashboardmenu");
|
App.closeWindow("dashboardmenu");
|
||||||
Utils.execAsync(action)
|
Utils.execAsync(action)
|
||||||
.then(res => res)
|
.then((res) => {
|
||||||
.catch(err => err);
|
if (typeof resolver === "function") {
|
||||||
|
return resolver(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.catch((err) => err);
|
||||||
|
};
|
||||||
return Widget.Box({
|
return Widget.Box({
|
||||||
class_name: "shortcuts-container",
|
class_name: "shortcuts-container",
|
||||||
hpack: "fill",
|
hpack: "fill",
|
||||||
@@ -72,7 +92,7 @@ const Shortcuts = () => {
|
|||||||
children: [
|
children: [
|
||||||
Widget.Button({
|
Widget.Button({
|
||||||
class_name: "dashboard-button colorpicker top-button",
|
class_name: "dashboard-button colorpicker top-button",
|
||||||
on_primary_click: () => handleClick("hyprpicker"),
|
on_primary_click: () => handleClick("hyprpicker -a"),
|
||||||
child: Widget.Label({
|
child: Widget.Label({
|
||||||
class_name: "button-label",
|
class_name: "button-label",
|
||||||
label: "",
|
label: "",
|
||||||
@@ -80,7 +100,10 @@ const Shortcuts = () => {
|
|||||||
}),
|
}),
|
||||||
Widget.Button({
|
Widget.Button({
|
||||||
class_name: "dashboard-button settings",
|
class_name: "dashboard-button settings",
|
||||||
on_primary_click: () => handleClick('bash -c "kitty -e nvim $HOME/.config/hypr/hyprland.conf"'),
|
on_primary_click: () =>
|
||||||
|
handleClick(
|
||||||
|
'bash -c "kitty -e nvim $HOME/.config/hypr/hyprland.conf"',
|
||||||
|
),
|
||||||
child: Widget.Label({
|
child: Widget.Label({
|
||||||
class_name: "button-label",
|
class_name: "button-label",
|
||||||
label: "",
|
label: "",
|
||||||
@@ -94,15 +117,32 @@ const Shortcuts = () => {
|
|||||||
children: [
|
children: [
|
||||||
Widget.Button({
|
Widget.Button({
|
||||||
class_name: "dashboard-button snapshot top-button",
|
class_name: "dashboard-button snapshot top-button",
|
||||||
on_primary_click: () => handleClick("grimblast --notify copysave area"),
|
on_primary_click: () =>
|
||||||
|
handleClick("grimblast --notify copysave area"),
|
||||||
child: Widget.Label({
|
child: Widget.Label({
|
||||||
class_name: "button-label",
|
class_name: "button-label",
|
||||||
label: "",
|
label: "",
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
Widget.Button({
|
Widget.Button({
|
||||||
class_name: "dashboard-button record",
|
class_name: isRecording
|
||||||
on_primary_click: () => handleClick("rofi -show drun"),
|
.bind("value")
|
||||||
|
.as((v) => `dashboard-button record ${v ? "active" : ""}`),
|
||||||
|
setup: (self) => {
|
||||||
|
self.hook(isRecording, () => {
|
||||||
|
self.on_primary_click = () => {
|
||||||
|
App.closeWindow("dashboardmenu");
|
||||||
|
if (isRecording.value === true) {
|
||||||
|
return Utils.execAsync(
|
||||||
|
`${App.configDir}/services/screen_record.sh stop`,
|
||||||
|
).catch((err) => console.error(err));
|
||||||
|
}
|
||||||
|
return Utils.execAsync(
|
||||||
|
`${App.configDir}/services/screen_record.sh start ${hyprland.active.monitor.name}`,
|
||||||
|
).catch((err) => console.error(err));
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
child: Widget.Label({
|
child: Widget.Label({
|
||||||
class_name: "button-label",
|
class_name: "button-label",
|
||||||
label: "",
|
label: "",
|
||||||
|
|||||||
@@ -123,7 +123,13 @@ export default () => {
|
|||||||
hexpand: true,
|
hexpand: true,
|
||||||
class_name: "notification-action-buttons menu",
|
class_name: "notification-action-buttons menu",
|
||||||
on_primary_click: () => {
|
on_primary_click: () => {
|
||||||
|
if (action.id.includes("scriptAction:-")) {
|
||||||
|
Utils.execAsync(
|
||||||
|
`${action.id.replace("scriptAction:-", "")}`,
|
||||||
|
).catch((err) => console.error(err));
|
||||||
|
} else {
|
||||||
notif.invoke(action.id);
|
notif.invoke(action.id);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Widget.Box({
|
child: Widget.Box({
|
||||||
hpack: "center",
|
hpack: "center",
|
||||||
|
|||||||
@@ -57,7 +57,13 @@ export default () => {
|
|||||||
hexpand: true,
|
hexpand: true,
|
||||||
class_name: "notification-action-buttons",
|
class_name: "notification-action-buttons",
|
||||||
on_primary_click: () => {
|
on_primary_click: () => {
|
||||||
|
if (action.id.includes("scriptAction:-")) {
|
||||||
|
Utils.execAsync(
|
||||||
|
`${action.id.replace("scriptAction:-", "")}`,
|
||||||
|
).catch((err) => console.error(err));
|
||||||
|
} else {
|
||||||
notif.invoke(action.id);
|
notif.invoke(action.id);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Widget.Box({
|
child: Widget.Box({
|
||||||
hpack: "center",
|
hpack: "center",
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
.bar_item_box_visible {
|
.bar_item_box_visible {
|
||||||
background-color: $base2;
|
background-color: $base2;
|
||||||
border-radius: 0.35em;
|
border-radius: 0.35em;
|
||||||
// border: 0.15em solid $surface0;
|
|
||||||
padding: 0.2rem 0.9rem;
|
padding: 0.2rem 0.9rem;
|
||||||
margin: 0.5rem 0.25rem;
|
margin: 0.5rem 0.25rem;
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,10 @@
|
|||||||
|
|
||||||
&.record.active {
|
&.record.active {
|
||||||
background: $red;
|
background: $red;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: $green;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
@@ -196,7 +200,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
trough {
|
trough {
|
||||||
min-height: 1.2em;
|
min-height: 1.05em;
|
||||||
}
|
}
|
||||||
|
|
||||||
block {
|
block {
|
||||||
|
|||||||
51
services/screen_record.sh
Normal file → Executable file
51
services/screen_record.sh
Normal file → Executable file
@@ -1,9 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
outputDir="$HOME/Videos"
|
outputDir="$HOME/Videos/Screencasts"
|
||||||
|
|
||||||
checkRecording() {
|
checkRecording() {
|
||||||
if pgrep -x "gpu-screen-recorder" > /dev/null; then
|
if pgrep -f "gpu-screen-recorder" > /dev/null; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
@@ -16,38 +16,18 @@ startRecording() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$2" ]; then
|
target="$2"
|
||||||
echo "Usage: $0 start {screen|window} [screen_name|window_id]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mode="$2"
|
outputFile="recording_$(date +%Y-%m-%d_%H-%M-%S).mkv"
|
||||||
target="$3"
|
|
||||||
|
|
||||||
outputFile="recording_$(date +%Y-%m-%d_%H-%M-%S).mp4"
|
|
||||||
outputPath="$outputDir/$outputFile"
|
outputPath="$outputDir/$outputFile"
|
||||||
mkdir -p "$outputDir"
|
mkdir -p "$outputDir"
|
||||||
|
|
||||||
case "$mode" in
|
|
||||||
screen)
|
|
||||||
if [ -z "$target" ]; then
|
if [ -z "$target" ]; then
|
||||||
echo "Usage: $0 start screen [screen_name]"
|
echo "Usage: $0 start screen [screen_name]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gpu-screen-recorder -w "$target" -f 60 -a "$(pactl get-default-sink).monitor" -o "$outputPath" &
|
gpu-screen-recorder -w "$target" -f 60 -a "$(pactl get-default-sink).monitor" -o "$outputPath" &
|
||||||
;;
|
|
||||||
window)
|
|
||||||
if [ -z "$target" ]; then
|
|
||||||
echo "Usage: $0 start window [window_id]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
gpu-screen-recorder -w "$target" -f 60 -a "$(pactl get-default-sink).monitor" -o "$outputPath" &
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Invalid mode. Use 'screen' or 'window'."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "Recording started. Output will be saved to $outputPath"
|
echo "Recording started. Output will be saved to $outputPath"
|
||||||
}
|
}
|
||||||
@@ -58,19 +38,18 @@ stopRecording() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pkill -SIGINT gpu-screen-recorder
|
pkill -f gpu-screen-recorder
|
||||||
recentFile=$(ls -t "$outputDir"/recording_*.mp4 | head -n 1)
|
recentFile=$(ls -t "$outputDir"/recording_*.mkv | head -n 1)
|
||||||
notify-send "Recording stopped" "Your recording has been saved." \
|
notify-send "Recording stopped" "Your recording has been saved." \
|
||||||
-i video-x-generic \
|
-i video-x-generic \
|
||||||
-a "Screen Recorder" \
|
-a "Screen Recorder" \
|
||||||
-t 10000 \
|
-t 10000 \
|
||||||
-u normal \
|
-u normal \
|
||||||
--action="open_directory=xdg-open $outputDir" \
|
--action="scriptAction:-dolphin $outputDir=Directory" \
|
||||||
--action="play_recording=xdg-open $recentFile"
|
--action="scriptAction:-xdg-open $recentFile=Play"
|
||||||
echo "Recording stopped. Output saved to $recentFile"
|
}
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
startRecording "$@"
|
startRecording "$@"
|
||||||
;;
|
;;
|
||||||
@@ -79,13 +58,13 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
if checkRecording; then
|
if checkRecording; then
|
||||||
echo "A recording is in progress."
|
echo "recording"
|
||||||
else
|
else
|
||||||
echo "No recording is in progress."
|
echo "not recording"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {start {screen|window} [screen_name|window_id]|stop|status}"
|
echo "Usage: $0 {start [screen_name|window_id]|stop|status}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -1397,6 +1397,9 @@ window#powermenu .powermenu.box {
|
|||||||
.dashboard-content-items .shortcuts-container .container button.record.active {
|
.dashboard-content-items .shortcuts-container .container button.record.active {
|
||||||
background: #f38ba8;
|
background: #f38ba8;
|
||||||
}
|
}
|
||||||
|
.dashboard-content-items .shortcuts-container .container button.record.active:hover {
|
||||||
|
background: #a6e3a1;
|
||||||
|
}
|
||||||
.dashboard-content-items .shortcuts-container .container button:hover {
|
.dashboard-content-items .shortcuts-container .container button:hover {
|
||||||
background: #f5c2e7;
|
background: #f5c2e7;
|
||||||
}
|
}
|
||||||
@@ -1474,7 +1477,7 @@ window#powermenu .powermenu.box {
|
|||||||
transition: 200ms;
|
transition: 200ms;
|
||||||
}
|
}
|
||||||
.dashboard-content-items .stats-container .stat .stats-bar trough {
|
.dashboard-content-items .stats-container .stat .stats-bar trough {
|
||||||
min-height: 1.2em;
|
min-height: 1.05em;
|
||||||
}
|
}
|
||||||
.dashboard-content-items .stats-container .stat .stats-bar block {
|
.dashboard-content-items .stats-container .stat .stats-bar block {
|
||||||
border-radius: 0.4em;
|
border-radius: 0.4em;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user