Skip to content

Commit 601c931

Browse files
committed
isinteractive: more fidelity
1 parent abb17bc commit 601c931

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

+stdlib/isinteractive.m

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
%% ISINTERACTIVE tell if being run interactively
22
%
3-
% NOTE: don't use batchStartupOptionUsed as it neglects the "-nodesktop" case
3+
% we try to consider the "-nodesktop" mode as interactive.
4+
% * get(0,'ScreenSize') often isn't relable anymore, it will show a display
5+
% size on HPC for example, maybe due to Xvfb or such.
6+
% Nowadays (R2025a+) one can make plots without Java enabled -nojvm too.
7+
48

59
function g = isinteractive()
610

7-
if stdlib.isoctave()
8-
g = ~isempty(graphics_toolkit());
9-
else
11+
if batchStartupOptionUsed()
12+
g = false;
13+
elseif stdlib.is_matlab_online()
14+
g = true;
15+
elseif isMATLABReleaseOlderThan('R2025a')
1016
g = usejava('desktop');
17+
elseif feature('showFigureWindows')
18+
% this is true in matlab -batch by default
19+
g = true;
20+
else
21+
% assume true to be 'safe'
22+
g = true;
1123
end
1224

1325
end

0 commit comments

Comments
 (0)