+#include <msp/core/application.h>
+#include <msp/graphics/display.h>
+#include <msp/io/print.h>
+
+using namespace std;
+using namespace Msp;
+
+class LsModes: public RegisteredApplication<LsModes>
+{
+private:
+ Graphics::Display display;
+
+public:
+ LsModes(int, char **);
+
+ virtual int main();
+};
+
+LsModes::LsModes(int, char **)
+{
+}
+
+int LsModes::main()
+{
+ const vector<Graphics::Monitor> &monitors = display.get_monitors();
+ const Graphics::VideoMode &desktop_mode = display.get_desktop_mode();
+ unsigned n = 0;
+ for(auto i=monitors.begin(); i!=monitors.end(); ++i, ++n)
+ {
+ IO::print("Monitor #%d", n);
+ if(&*i==desktop_mode.monitor)
+ IO::print(" (primary)");
+ IO::print(": %s\n", i->name);
+
+ const Graphics::VideoMode *prev_mode = 0;
+ for(const Graphics::VideoMode *m: i->video_modes)
+ {
+ if(!prev_mode || m->width!=prev_mode->width || m->height!=prev_mode->height)
+ {
+ if(prev_mode)
+ IO::print("\n");
+ IO::print(" %dx%d", m->width, m->height);
+ }
+ IO::print(" %c%d", (m==i->desktop_settings.mode ? '*' : ' '), m->rate);
+ prev_mode = m;
+ }
+
+ if(!i->video_modes.empty())
+ IO::print("\n\n");
+ }
+
+ return 0;
+}