You can use the ifthen
package in this way
\documentclass{beamer}
%\documentclass[aspectratio=169]{beamer}
\usepackage{ifthen}
\makeatletter
\newcommand{\prova}{Aspect ratio is 4:3 (default)}
\ifthenelse{%
\lengthtest{\beamer@paperwidth=16cm}}% condition (16cm is the width of the frame with an aspect ratio = 16:9)
{\renewcommand{\prova}{Aspect ratio is 16:9}}% do this if condition is true
{}% do nothing elsewhere
\makeatother
\begin{document}
\begin{frame}
\prova
\end{frame}
\end{document}
And you can add others constructs like this
\ifthenelse{%
\lengthtest{\beamer@paperwidth=16cm}}% condition (16cm is the width of the frame with an aspect ratio = 16:9)
{\renewcommand{\prova}{Aspect ratio is 16:9}}% do this if condition is true
{}% do nothing elsewhere
to add other "supported" aspect ratios. But if you want to create something more universal (not only for you and not only for 16:9 or 4:3 aspect) you have to be careful because different aspect ratios can have the same paperwidth
or the same paperheight
. A solution can be to have two \ifthenelse
one inside the other.
This is how the paper dimensions are defined for different aspect ratio into the beamer.cls
class file
\DeclareOptionBeamer{aspectratio}[43]{%
\ifnum#1=1610%
\beamer@paperwidth 16.00cm%
\beamer@paperheight 10.00cm%
\else\ifnum#1=169%
\beamer@paperwidth 16.00cm%
\beamer@paperheight 9.00cm%
\else\ifnum#1=149%
\beamer@paperwidth 14.00cm%
\beamer@paperheight 9.00cm%
\else\ifnum#1=54%
\beamer@paperwidth 12.50cm%
\beamer@paperheight 10.00cm%
\else\ifnum#1=43%
\beamer@paperwidth 12.80cm%
\beamer@paperheight 9.60cm%
\else\ifnum#1=32%
\beamer@paperwidth 13.50cm%
\beamer@paperheight 9.00cm%
\fi\fi\fi\fi\fi\fi%
}