[Question]
  [
Output the device's screen resolution in the **specific** format of `[width]x[height]`(without the brackets). For example, an output could be `1440x900`.
[Here's an online tester that you can use to check your own screen resolution.](http://www.whatismyscreenresolution.com/)
  
[Answer]
# JavaScript (ES6), 32 bytes
```
(_=screen)=>_.width+"x"+_.height
```
Outputs as function `return`. Add `f=` at the beginning and invoke like `f()`. Uses parameter-initializing to initialize the parameter `_` to `screen` object. The rest is self-explanatory.
```
f=(_=screen)=>_.width+"x"+_.height
console.log(f())
```
**Note:** Passing an argument to this function will cause it to fail.
---
# JavaScript (Previous Solution), 35 bytes
```
with(screen)alert(width+"x"+height)
```
Never thought I will one day use `with`! I don't think this can be golfed further.
[Answer]
# TI-BASIC, ~~30~~ ~~32~~ 29 bytes (non-competing?)
\*sigh\* TI-BASIC takes an extra byte for every lowercase letter.
+2 thanks to [@Timtech](https://codegolf.stackexchange.com/users/10740/timtech)
-3 thanks to [@Timtech](https://codegolf.stackexchange.com/users/10740/timtech)
```
:If ΔX>.1
:Then
:Disp "96x64
:Else
:Disp "320x240
```
This only works because TI-BASIC can only be run on calculators with two different screen resolutions: 96 by 64 and 320 by 240. I just test to see which screen I have by setting the Zoom to something that is different depending on screen resolution then outputting the correct resolution.
I'm marking this as non-competing for now, since it is hard coded.
[Answer]
# JavaScript (ES6), 32 bytes
```
_=>(s=screen).width+'x'+s.height
```
```
console.log((_=>(s=screen).width+'x'+s.height)())
```
[Answer]
# macOS, bash, awk, ~~grep, tr, 51~~ 52 bytes
```
/*/*/sy*r SPDisplaysDataType|awk '/so/{print$2$3$4}'
```
Runs `system_profiler`, gets the `SPDisplaysDataType` information, searches for the first `so` in `Resolution`, and prints the screen resolution. For multiple screens, this prints all resolutions.
[![Example of the command running.](https://i.stack.imgur.com/egNTU.png)](https://i.stack.imgur.com/egNTU.png)
---
The prior, malcompliant variant:
```
/*/*/sy*r SPDisplaysDataType|grep so|tr -d 'R :a-w'
```
[Answer]
# Javascript, 36 bytes
```
s=screen;alert(s.width+"x"+s.height)
```
[Answer]
# Processing 3, 37 bytes
```
fullScreen();print(width+"x"+height);
```
`fullScreen()` causes the app to launch with the maximum dimensions - the display resolution.
One byte less than the obvious
```
print(displayWidth+"x"+displayHeight);
```
[Answer]
# AutoHotKey, 34 bytes
```
SysGet,w,0
SysGet,h,1
Send,%w%x%h%
```
Save this in a file with extension .AHK and run it from a command prompt
[Answer]
# C (Windows), ~~79~~ ~~78~~ 77 bytes
*Thanks to @Johan du Toit for saving a byte!*
```
#import<windows.h>
#define G GetSystemMetrics
f(){printf("%dx%d",G(0),G(1));}
```
[Answer]
# PowerShell, ~~67~~ ~~60~~ 55 Bytes
-7 thanks to [Martin Ender](https://chat.stackexchange.com/transcript/message/37106916#37106916)
-5 (actually 12!) from [Leaky Nun](https://chat.stackexchange.com/transcript/message/37107030#37107030) , Regex wizardry is beyond me.
This is long but not longer than the horrendous `System.Windows.Forms.SystemInformation.PrimaryMonitorSize` solution
```
(gwmi win32_videocontroller|% v*n)-replace" |x \d+\D+$"
```
first we `Get-WmiObject`(`gwmi`) to retrieve the `Win32_VideoController` object, which contains a member named `VideoModeDescription`, which is a string in the format of `1920 x 1080 x 4294967296 colors`, then I run a regex replace to get correct format.
```
PS H:\> (gwmi win32_videocontroller|% v*n)-replace" |x \d+\D+$"
1920x1080
```
[Answer]
## Mathematica, 51 bytes
```
SystemInformation[][[1,5,2,1,2,1,2,2,;;,2]]~Infix~x
```
This may not work for you depending on what devices you have connected (I don't know). This should always work (assuming you have at least one screen hooked up):
```
Infix[Last/@("FullScreenArea"/.SystemInformation["Devices","ScreenInformation"][[1]]),x]
```
## Explanation
`SystemInformation[]` returns an expression of the form 
```
SystemInformationData[{
  "Kernel" -> {__},
  "FrontEnd" -> {__},
  "Links" -> {__},
  "Parallel" -> {__},
  "Devices" -> {__},
  "Network" -> {__},
}]
```
We are interested in `"Devices"`, which can be accessed directly as `SystemInformation["Devices"]` or as `SystemInformation[][[1,5,2]]`. The result will be a list of the form
```
{
  "ScreenInformation" -> {__},
  "GraphicsDevices" -> {__},
  "ControllerDevices" -> {__}
}
```
We want `"ScreenInformation"`, which can be accessed either as `SystemInformation["Devices","ScreenInformation"]` or more succinctly as `SystemInformation[][[1,5,2,1,2]]`. The result will be of the form
```
{
  {
  "ScreenArea" -> {__},
  "FullScreenArea" -> {{0,w_},{0,h_}},
  "BitDepth" -> _,
  "Resolution" -> _
  },
  ___
}
```
The length of the list will be the number of screens you have connected. The first screen is `SystemInformation[][[1,5,2,1,2,1]]` and the width and height can be extracted as `SystemInformation[][[1,5,2,1,2,1,2,2,;;,2]]` Then we just insert an `Infix` `x` for the output format.
[Answer]
# Java 7, ~~123~~ 114 bytes
```
String f(){java.awt.Dimension s=java.awt.Toolkit.getDefaultToolkit().getScreenSize();return s.width+"x"+s.height;}
```
This method will not work in a headless installation of Java (like on TIO) because it uses the awt libraries. Under the hood, calling `getScreenSize` uses the Java Native Interface to call out (typically into a C library) for the screen width and screen height.
-9 bytes thanks to [Olivier Grégoire](https://codegolf.stackexchange.com/users/16236/olivier-gr%C3%A9goire) for reminding me that I can return the string instead of printing it.
[Answer]
# C#, ~~101~~ ~~95~~ 89 bytes
```
_=>{var s=System.Windows.Forms.Screen.PrimaryScreen.Bounds;return s.Width+"x"+s.Height;};
```
-6 bytes thanks to *@TheLethalCoder* by reminding me OP didn't mention about printing, so returning a string is also fine. And an additional -6 bytes by changing it to a lambda.
[Answer]
# Bash + xrandr, 44 characters
```
read -aa<<<`xrandr`
echo ${a[7]}x${a[9]::-1}
```
`xrandr` belongs to the X server, on Ubuntu is provided by [*x11-xserver-utils*](http://packages.ubuntu.com/yakkety/amd64/x11-xserver-utils/filelist) package.
Sample run:
```
bash-4.3$ read -aa<<<`xrandr`;echo ${a[7]}x${a[9]::-1}
1920x1080
```
## xrandr + grep + util-linux, 30 characters
```
xrandr|grep -oP '\d+x\d+'|line
```
Thanks to:
* [Markasoftware](https://codegolf.stackexchange.com/users/10973/markasoftware) for the regular expression (-11 characters)
Sample run:
```
bash-4.3$ xrandr|grep -oP '\d+x\d+'|line
1920x1080
```
[Answer]
# Python 2, 73 bytes
```
from ctypes import*
u=windll.user32.GetSystemMetrics;
print u(0),'x',u(1)
```
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 41 bytes
*Thanks to [@Arjun](https://codegolf.stackexchange.com/users/45105/arjun) and [@StephenS](https://codegolf.stackexchange.com/users/65836/stephen-s) for corrections.*
```
fprintf('%ix%i',get(0,'ScreenSize')(3:4))
```
`0` is a handle to the root graphics object. Its property `'ScreenSize'` contains the coordinates of the screen in pixels. The third and fourth entries give the desired information.
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 23 bytes
```
' '⎕R'x'⍕⌽⊃⎕WG'DevCaps'
```
`⎕WG'DevCaps'` **W**indow **G**et **Dev**ice **Cap**abilitie**s**
`⊃` pick the first property (height, width)
`⌽` reverse
`⍕` format as text
`' '⎕R'x'` **R**eplace spaces with "x"s
[Answer]
## [Japt](https://github.com/ETHproductions/japt), 24 bytes
```
Ox`ØP(s×Çn)±d+"x"+ight
```
[Test it online!](http://ethproductions.github.io/japt/?v=1.4.4&code=T3hg2FAoc9fHbimxZJArIngiK5RpZ2h0&input=)
The compressed string represents `with(screen)width+"x"+height`. `Ox` evaluates this as JavaScript, and the result is implicitly printed.
[Answer]
# C (SDL2 library) ~~113~~ ~~88~~ 84
(-4 chars due to @AppleShell 's help)
Yes. it compiles.
```
m[3];main(){SDL_Init(32);SDL_GetDesktopDisplayMode(0,m);printf("%dx%d",m[1],m[2]);}
```
Run with : `gcc snippet.c -lSDL2 && ./a.out`
[Answer]
[`xrandr`](https://www.x.org/archive/X11R7.5/doc/man/man1/xrandr.1.html) + awk, 25 bytes
```
xrandr|awk /\*/{print\$1}
```
---
[![enter image description here](https://i.stack.imgur.com/Zplu4.gif)](https://i.stack.imgur.com/Zplu4.gif)
[Answer]
# Python 2, ~~61~~ 49 bytes
Thanks @Jonathan-allan, @felipe-nardi-batista
```
from Tkinter import*
print'%sx%s'%Tk().maxsize()
```
For single display setups, this matches the output from the site. This gives entire resolution for multiple displays. 
[Answer]
# ZX Spectrum Basic, 10 bytes
just for completeness:
```
PRINT "256x192"
```
outputs `256x192`. The Spectrum has a fixed hardwired screen resolution.
[Answer]
## bash + xdpyinfo  ~~42~~  31 bytes
```
xdpyinfo|grep dim|cut -d' ' -f7
```
From man page:
```
xdpyinfo - is  a utility for displaying information about an X server.
```
@Floris @manatwork Thanks for saving a few bytes!
[Answer]
# Processing, 51 bytes
```
void setup(){fullScreen();print(width+"x"+height);}
```
This outputs in this format: `width height`. Also, the program creates a window that is the size of the screen you are using (because every Processing program creates a window by default) and this program just outputs the height and the width of this window/sketch.
[Answer]
### `xdpyinfo` + `awk`, 28 bytes
```
$ xdpyinfo|awk /dim/{print\$2}
3360x1050
```
Tested on Cygwin with dual heads.
[Answer]
# Racket, 73 bytes
```
#!racket/gui
(let-values([(x y)(get-display-size #t)])(printf"~ax~a"x y))
```
Just discovered the [(discouraged) shorthand for `#lang`](https://docs.racket-lang.org/reference/reader.html#%28part._parse-reader%29). Saves a few bytes! [Documentation for `get-display-size`](https://docs.racket-lang.org/gui/Windowing_Functions.html?q=gui#%28def._%28%28lib._mred%2Fmain..rkt%29._get-display-size%29%29).
[Answer]
# Tcl/Tk, 40
```
puts [winfo screenw .]x[winfo screenh .]
```
[Answer]
## [Lithp](https://github.com/andrakis/node-lithp), 116 bytes
```
((import html-toolkit)
(htmlOnLoad #::((var S(index(getWindow)screen))
(print(+(index S width)"x"(index S height))))))
```
(Line breaks added for readability)
[Try it online!](https://andrakis.github.io/ide2/index.html?code=KChpbXBvcnQgaHRtbC10b29sa2l0KShodG1sT25Mb2FkICM6OigodmFyIFMoaW5kZXgoZ2V0V2luZG93KXNjcmVlbikpKHByaW50KCsoaW5kZXggUyB3aWR0aCkieCIoaW5kZXggUyBoZWlnaHQpKSkpKSk=)
Finally, my html-toolkit module gets some use! Only works in the Try it Online link, will not work from command line.
A few bytes could be saved if `1024 x 768` could be valid output. We just use `(+ .. "x" .. )` to avoid `print`'s implicit spacing.
[Answer]
# Lua (löve framework),116 bytes
```
f,g=love.window.setFullscreen,love.graphics function love.draw()f(1)w,h=g.getDimensions()f(0>1)g.print(w.."x"..h)end
```
The programm changes first to fullscreen then it gets the width and height and prints it then :) 
[Answer]
### xrandr and sh, 23 bytes
```
$ set `xrandr`;echo $6x$8
3360x1050
```
Tested on a CentOS 5 box with display redirected to a Cygwin machine with two monitors. Here the full `xrandr` output is
```
$ xrandr
 SZ:    Pixels          Physical       Refresh
*0   3360 x 1050   ( 889mm x 278mm )  *0
Current rotation - normal
Current reflection - none
Rotations possible - normal
Reflections possible - none
```
[Answer]
## Ruby + xrandr, 37 bytes
```
puts `xrandr`.split[7..9].join[0..-2]
```
Alternate solution (52 bytes):
```
puts `xrandr`.match(/t (\d+) (x) (\d+),/)[1..3].join
```
]