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
5 changes: 4 additions & 1 deletion data/com.github.mohelm97.screenrecorder.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<key name="mouse-pointer" type="b">
<default>true</default>
</key>
<key name="keys" type="b">
<default>true</default>
</key>
<key name="show-borders" type="b">
<default>true</default>
</key>
Expand All @@ -42,4 +45,4 @@
<default>"screen"</default>
</key>
</schema>
</schemalist>
</schemalist>
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ Standards-Version: 3.9.3

Package: com.github.mohelm97.screenrecorder
Architecture: any
Depends: ffmpeg, ${misc:Depends}, ${shlibs:Depends}
Depends: screenkey, ffmpeg, ${misc:Depends}, ${shlibs:Depends}
Description: Simple screen recorder
A screen recorder with the ability to produce gifs, mp4, mov, and recording sounds from computer and microphone using ffmpeg.
52 changes: 42 additions & 10 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ namespace ScreenRecorder {
private Gtk.Switch record_cmp_switch;
private Gtk.Switch record_mic_switch;
private Gtk.Switch pointer_switch;
private Gtk.Switch keys_switch;
private Gtk.Switch borders_switch;
private Gtk.ComboBoxText format_cmb;
private Subprocess screenkey_process;

private bool recording = false;
private bool save_dialog_present = false;
Expand Down Expand Up @@ -79,6 +81,12 @@ namespace ScreenRecorder {
pointer_switch = new Gtk.Switch ();
pointer_switch.halign = Gtk.Align.START;

var keys_label = new Gtk.Label (_("Grab keyboard:"));
keys_label.halign = Gtk.Align.END;

keys_switch = new Gtk.Switch ();
keys_switch.halign = Gtk.Align.START;

var record_cmp_label = new Gtk.Label (_("Record computer sounds:"));
record_cmp_label.halign = Gtk.Align.END;

Expand Down Expand Up @@ -155,16 +163,18 @@ namespace ScreenRecorder {
grid.attach (record_mic_switch , 1, 2, 1, 1);
grid.attach (pointer_label , 0, 3, 1, 1);
grid.attach (pointer_switch , 1, 3, 1, 1);
grid.attach (borders_label , 0, 4, 1, 1);
grid.attach (borders_switch , 1, 4, 1, 1);
grid.attach (delay_label , 0, 5, 1, 1);
grid.attach (delay_spin , 1, 5, 1, 1);
grid.attach (framerate_label , 0, 6, 1, 1);
grid.attach (framerate_spin , 1, 6, 1, 1);
grid.attach (scale_label , 0, 7, 1, 1);
grid.attach (scale_combobox , 1, 7, 1, 1);
grid.attach (format_label , 0, 8, 1, 1);
grid.attach (format_cmb , 1, 8, 1, 1);
grid.attach (keys_label , 0, 4, 1, 1);
grid.attach (keys_switch , 1, 4, 1, 1);
grid.attach (borders_label , 0, 5, 1, 1);
grid.attach (borders_switch , 1, 5, 1, 1);
grid.attach (delay_label , 0, 6, 1, 1);
grid.attach (delay_spin , 1, 6, 1, 1);
grid.attach (framerate_label , 0, 7, 1, 1);
grid.attach (framerate_spin , 1, 7, 1, 1);
grid.attach (scale_label , 0, 8, 1, 1);
grid.attach (scale_combobox , 1, 8, 1, 1);
grid.attach (format_label , 0, 9, 1, 1);
grid.attach (format_cmb , 1, 9, 1, 1);

var mode_switch = new Granite.ModeSwitch.from_icon_name ("display-brightness-symbolic", "weather-clear-night-symbolic");
mode_switch.primary_icon_tooltip_text = _("Light background");
Expand Down Expand Up @@ -195,6 +205,7 @@ namespace ScreenRecorder {
settings.bind ("dark-theme", mode_switch, "active", GLib.SettingsBindFlags.DEFAULT);
settings.bind ("record-computer", record_cmp_switch, "active", GLib.SettingsBindFlags.DEFAULT);
settings.bind ("record-microphone", record_mic_switch, "active", GLib.SettingsBindFlags.DEFAULT);
settings.bind ("keys", keys_switch, "active", GLib.SettingsBindFlags.DEFAULT);
settings.bind ("mouse-pointer", pointer_switch, "active", GLib.SettingsBindFlags.DEFAULT);
settings.bind ("show-borders", borders_switch, "active", GLib.SettingsBindFlags.DEFAULT);
settings.bind ("delay", delay_spin, "value", GLib.SettingsBindFlags.DEFAULT);
Expand Down Expand Up @@ -339,10 +350,31 @@ namespace ScreenRecorder {
actions.remove (record_btn);
actions.add (stop_btn);
stop_btn.show ();
if (keys_switch.state) {
screenkeys (selection_rect);
}
}

void screenkeys (Gdk.Rectangle area) {
try {
string[] command = {
"screenkey",
"--no-detach",
"-g",
"%ix%i+%i+%i".printf(area.width, area.height, area.x, area.y)
};
screenkey_process = new Subprocess.newv (command, SubprocessFlags.NONE);
} catch (Error e) {
debug ("Issue running screenkey: '%s'", e.message);
}
}

void stop_recording () {
ffmpegwrapper.stop();
if (screenkey_process != null) {
screenkey_process.force_exit ();
}

present ();
var save_dialog = new SaveDialog (tmpfilepath, this, last_recording_width, last_recording_height);
save_dialog_present = true;
Expand Down