Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
derf
feh
Commits
aaa67e2d
Commit
aaa67e2d
authored
7 years ago
by
Birte Kristina Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Add experimental support for (remote) control via stdin
parent
fd524633
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/feh.h
+1
-0
1 addition, 0 deletions
src/feh.h
src/keyevents.c
+15
-0
15 additions, 0 deletions
src/keyevents.c
src/main.c
+17
-0
17 additions, 0 deletions
src/main.c
with
33 additions
and
0 deletions
src/feh.h
+
1
−
0
View file @
aaa67e2d
...
...
@@ -142,6 +142,7 @@ char *thumbnail_create_name(feh_file * file, winwidget winwid);
void
init_keyevents
(
void
);
void
init_buttonbindings
(
void
);
void
feh_event_handle_keypress
(
XEvent
*
ev
);
void
feh_event_handle_stdin
();
void
feh_event_handle_generic
(
winwidget
winwid
,
unsigned
int
state
,
KeySym
keysym
,
unsigned
int
button
);
fehkey
*
feh_str_to_kb
(
char
*
action
);
void
feh_action_run
(
feh_file
*
file
,
char
*
action
,
winwidget
winwid
);
...
...
This diff is collapsed.
Click to expand it.
src/keyevents.c
+
15
−
0
View file @
aaa67e2d
...
...
@@ -266,6 +266,21 @@ void feh_event_invoke_action(winwidget winwid, unsigned char action)
return
;
}
void
feh_event_handle_stdin
()
{
char
stdin_buf
[
2
];
if
(
read
(
STDIN_FILENO
,
&
stdin_buf
,
1
)
==
-
1
)
{
weprintf
(
"reading a command from stdin failed"
);
return
;
}
stdin_buf
[
1
]
=
'\0'
;
KeySym
keysym
=
XStringToKeysym
(
stdin_buf
);
if
(
window_num
)
feh_event_handle_generic
(
windows
[
0
],
0
,
keysym
,
0
);
}
void
feh_event_handle_keypress
(
XEvent
*
ev
)
{
int
state
;
...
...
This diff is collapsed.
Click to expand it.
src/main.c
+
17
−
0
View file @
aaa67e2d
...
...
@@ -32,6 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include
"events.h"
#include
"signals.h"
#include
"wallpaper.h"
#include
<termios.h>
char
**
cmdargv
=
NULL
;
int
cmdargc
=
0
;
...
...
@@ -91,6 +92,7 @@ int feh_main_iteration(int block)
static
int
xfd
=
0
;
static
int
fdsize
=
0
;
static
double
pt
=
0
.
0
;
static
int
read_stdin
=
0
;
XEvent
ev
;
struct
timeval
tval
;
fd_set
fdset
;
...
...
@@ -107,6 +109,15 @@ int feh_main_iteration(int block)
fdsize
=
xfd
+
1
;
pt
=
feh_get_time
();
first
=
0
;
if
(
isatty
(
STDIN_FILENO
))
{
read_stdin
=
1
;
struct
termios
ctrl
;
if
(
tcgetattr
(
STDIN_FILENO
,
&
ctrl
)
==
-
1
)
eprintf
(
"tcgetattr failed"
);
ctrl
.
c_lflag
&=
~
ICANON
;
if
(
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
ctrl
)
==
-
1
)
eprintf
(
"tcsetattr failed"
);
}
}
/* Timers */
...
...
@@ -127,6 +138,8 @@ int feh_main_iteration(int block)
FD_ZERO
(
&
fdset
);
FD_SET
(
xfd
,
&
fdset
);
if
(
read_stdin
)
FD_SET
(
STDIN_FILENO
,
&
fdset
);
/* Timers */
ft
=
first_timer
;
...
...
@@ -170,6 +183,8 @@ int feh_main_iteration(int block)
in that */
feh_handle_timer
();
}
else
if
(
count
&&
(
FD_ISSET
(
0
,
&
fdset
)))
feh_event_handle_stdin
();
}
}
else
{
/* Don't block if there are events in the queue. That's a bit rude ;-) */
...
...
@@ -181,6 +196,8 @@ int feh_main_iteration(int block)
&&
((
errno
==
ENOMEM
)
||
(
errno
==
EINVAL
)
||
(
errno
==
EBADF
)))
eprintf
(
"Connection to X display lost"
);
else
if
(
count
&&
(
FD_ISSET
(
0
,
&
fdset
)))
feh_event_handle_stdin
();
}
}
if
(
window_num
==
0
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment