summaryrefslogtreecommitdiffstats
path: root/.local
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2021-03-09 17:13:10 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2021-03-09 17:13:10 +0100
commitf3a02b2ceec9cabc4bdde0426ec0d5c084f69b45 (patch)
tree65587b92e729f3d5b46aecc698ba0649898228b4 /.local
parentnew script (diff)
downloaddotfiles-bsd-f3a02b2ceec9cabc4bdde0426ec0d5c084f69b45.tar.gz
dotfiles-bsd-f3a02b2ceec9cabc4bdde0426ec0d5c084f69b45.tar.bz2
dotfiles-bsd-f3a02b2ceec9cabc4bdde0426ec0d5c084f69b45.tar.xz
dotfiles-bsd-f3a02b2ceec9cabc4bdde0426ec0d5c084f69b45.tar.zst
dotfiles-bsd-f3a02b2ceec9cabc4bdde0426ec0d5c084f69b45.zip
new scripts
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/dmkill60
-rwxr-xr-x.local/bin/dmlog16
-rwxr-xr-x.local/bin/dmscrot118
-rwxr-xr-x.local/bin/linkview2
4 files changed, 187 insertions, 9 deletions
diff --git a/.local/bin/dmkill b/.local/bin/dmkill
new file mode 100755
index 0000000..87c91fd
--- /dev/null
+++ b/.local/bin/dmkill
@@ -0,0 +1,60 @@
+#!/usr/local/bin/perl
+
+use strict;
+use warnings;
+use File::HomeDir qw(home);
+use constant CONFIRM => [
+ "No",
+ "Yes"
+ ];
+
+sub confirm
+{
+ my ($pid, $proc) = @_;
+ my $list;
+ my $choice;
+
+ for (@{+CONFIRM}) {
+ $list .= $_ . "\n";
+ }
+ $choice = `printf "%s" "$list" | dmenu -i -p "Kill $proc ($pid)?" -l 2 -m 0`;
+ chomp $choice;
+ if ($choice eq ${+CONFIRM}[1]) {
+ return (1);
+ }
+ return (0);
+}
+
+sub action
+{
+ my ($var, $user) = @_;
+ my @split;
+ my $pid;
+ my $proc;
+
+ chomp $var;
+ @split = split / $user /, $var;
+ $pid = $split[0];
+ $pid =~ s/\D//g;
+ print $pid . "\n";
+ $proc = (split / /, $split[1])[0];
+ print $proc . "\n";
+ if (confirm($pid, $proc) == 1) {
+ }
+ return;
+}
+
+sub main
+{
+ my $choice;
+ my $user;
+
+ $user = getlogin();
+ $choice = `ps -U "$user" -o pid,user,command | dmenu -i -l 30 -m 0`;
+ action($choice, $user);
+ return (0);
+}
+
+main();
+
+__END__
diff --git a/.local/bin/dmlog b/.local/bin/dmlog
index 423bc2e..b87bbf5 100755
--- a/.local/bin/dmlog
+++ b/.local/bin/dmlog
@@ -9,11 +9,11 @@ use constant {
SHUTDOWN_PATH => '/sbin/shutdown'
};
use constant LIST => [
- "Lock screen",
- "Sleep",
- "Logout",
- "Shutdown",
- "Reboot"
+ 'Lock screen',
+ 'Sleep',
+ 'Logout',
+ 'Shutdown',
+ 'Reboot'
];
use constant CONFIRM => [
"No",
@@ -29,7 +29,7 @@ sub confirm
for (@{+CONFIRM}) {
$list .= $_ . "\n";
}
- $choice = `printf "%s" "$list" | dmenu -p "$var:"`;
+ $choice = `printf "%s" "$list" | dmenu -i -p "$var?" -l 2 -m 0`;
chomp $choice;
if ($choice eq ${+CONFIRM}[1]) {
return (1);
@@ -51,7 +51,7 @@ sub action
if (not $pid) {
exec(SLOCK_PATH);
}
- els{
+ else {
exec(ACPI_PATH, '-s', '3');
}
}
@@ -81,7 +81,7 @@ sub main
for (@{+LIST}) {
$list .= $_ . "\n";
}
- $choice = `printf "%s" "$list" | dmenu`;
+ $choice = `printf "%s" "$list" | dmenu -i -l 5 -m 0`;
action($choice);
return (0);
}
diff --git a/.local/bin/dmscrot b/.local/bin/dmscrot
new file mode 100755
index 0000000..e68f258
--- /dev/null
+++ b/.local/bin/dmscrot
@@ -0,0 +1,118 @@
+#!/usr/local/bin/perl
+
+use strict;
+use warnings;
+use File::HomeDir qw(home);
+use constant {
+ SAVE_PATH => 'pics/scrot/',
+ SCREENSHOT_PATH => '/usr/local/bin/scrot',
+ IMGVIEW_PATH => '/usr/local/bin/sxiv',
+ XCLIP_PATH => '/usr/local/bin/xclip'
+};
+use constant LIST => [
+ 'Select region',
+ 'Window',
+ 'Fullscreen',
+ 'Monitor 1',
+ 'Monitor 2'
+ ];
+
+sub show_img
+{
+ my ($file) = @_;
+ my $pid;
+
+ $pid = fork();
+ if (not $pid) {
+ exec(IMGVIEW_PATH, '-b', $file);
+ }
+ return;
+}
+
+sub file_name
+{
+ my $file_name;
+
+ $file_name = home() . '/' . SAVE_PATH . 'screen_';
+ $file_name .= `date "+%Y-%m-%d_%H-%M-%S"`;
+ chomp $file_name;
+ $file_name .= '.png';
+ return ($file_name);
+}
+
+sub action
+{
+ my ($var) = @_;
+ my $pid;
+ my $file_name;
+
+ chomp $var;
+ if ($var eq ${+LIST}[0]) {
+ $file_name = file_name();
+ system(
+ SCREENSHOT_PATH,
+ $file_name,
+ '-q', '100',
+ '-s',
+ '-l', 'mode=classic,style=dash,width=2,color=#990000'
+ );
+ show_img($file_name);
+ }
+ elsif ($var eq ${+LIST}[1]) {
+ $file_name = file_name();
+ system(
+ SCREENSHOT_PATH,
+ $file_name,
+ '-q', '100',
+ '-u'
+ );
+ show_img($file_name);
+ }
+ elsif ($var eq ${+LIST}[2]) {
+ $file_name = file_name();
+ system(
+ SCREENSHOT_PATH,
+ $file_name,
+ '-q', '100'
+ );
+ show_img($file_name);
+ }
+ elsif ($var eq ${+LIST}[3]) {
+ $file_name = file_name();
+ system(
+ SCREENSHOT_PATH,
+ $file_name,
+ '-q', '100',
+ '-a', '0,0,1920,1080'
+ );
+ show_img($file_name);
+ }
+ elsif ($var eq ${+LIST}[4]) {
+ $file_name = file_name();
+ system(
+ SCREENSHOT_PATH,
+ $file_name,
+ '-q', '100',
+ '-a', '1920,180,1440,900'
+ );
+ show_img($file_name);
+ }
+ return;
+}
+
+sub main
+{
+ my $list;
+ my $choice;
+
+ for (@{+LIST}) {
+ $list .= $_ . "\n";
+ }
+ $choice = `printf "%s" "$list" | dmenu -i -l 10 -m 0`;
+ action($choice);
+ return (0);
+}
+
+main();
+
+__END__
diff --git a/.local/bin/linkview b/.local/bin/linkview
index 3f39ffc..5cb6baf 100755
--- a/.local/bin/linkview
+++ b/.local/bin/linkview
@@ -243,7 +243,7 @@ sub dmenu_prompt
my $answer;
my $list = PROG_LIST;
- $answer = `printf "$list\nURL: $url\n" | dmenu -i -l 11`;
+ $answer = `printf "$list\nURL: $url\n" | dmenu -i -l 11 -m 0`;
chomp $answer;
return $answer;
}